62982a9a67
Reply to iCalendar invitations with three commands: :accept, :accept-tentative or :decline. Parse a text/calendar request, create a reply and append it to the composer. Suggested-by: Ondřej Synáček <ondrej@synacek.org> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package lib
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"git.sr.ht/~rjarry/aerc/models"
|
|
)
|
|
|
|
func FindPlaintext(bs *models.BodyStructure, path []int) []int {
|
|
for i, part := range bs.Parts {
|
|
cur := append(path, i+1)
|
|
if strings.ToLower(part.MIMEType) == "text" &&
|
|
strings.ToLower(part.MIMESubType) == "plain" {
|
|
return cur
|
|
}
|
|
if strings.ToLower(part.MIMEType) == "multipart" {
|
|
if path := FindPlaintext(part, cur); path != nil {
|
|
return path
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func FindCalendartext(bs *models.BodyStructure, path []int) []int {
|
|
for i, part := range bs.Parts {
|
|
cur := append(path, i+1)
|
|
if strings.ToLower(part.MIMEType) == "text" &&
|
|
strings.ToLower(part.MIMESubType) == "calendar" {
|
|
return cur
|
|
}
|
|
if strings.ToLower(part.MIMEType) == "multipart" {
|
|
if path := FindCalendartext(part, cur); path != nil {
|
|
return path
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func FindFirstNonMultipart(bs *models.BodyStructure, path []int) []int {
|
|
for i, part := range bs.Parts {
|
|
cur := append(path, i+1)
|
|
mimetype := strings.ToLower(part.MIMEType)
|
|
if mimetype != "multipart" {
|
|
return cur
|
|
} else if mimetype == "multipart" {
|
|
if path := FindFirstNonMultipart(part, cur); path != nil {
|
|
return path
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|