diff options
author | Drew DeVault <sir@cmpwn.com> | 2020-10-23 15:15:46 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-10-23 15:15:46 -0400 |
commit | 64b16f4a5039bee9a97d3c69db0b49c5a9217908 (patch) | |
tree | 5b3968c915da53f19d4f398c2c30a2bae3154b6e /plugins/base | |
parent | f97f38d4a9550bb15d39cfc05a3011e969927d22 (diff) | |
download | alps-64b16f4a5039bee9a97d3c69db0b49c5a9217908.tar.gz alps-64b16f4a5039bee9a97d3c69db0b49c5a9217908.zip |
message.html: add tabs to select html/plaintext
Diffstat (limited to 'plugins/base')
-rw-r--r-- | plugins/base/imap.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/plugins/base/imap.go b/plugins/base/imap.go index 3492e7e..07b69c7 100644 --- a/plugins/base/imap.go +++ b/plugins/base/imap.go @@ -210,6 +210,29 @@ func (msg *IMAPMessage) TextPart() *IMAPPartNode { return best } +func (msg *IMAPMessage) HTMLPart() *IMAPPartNode { + if msg.BodyStructure == nil { + return nil + } + + var best *IMAPPartNode + msg.BodyStructure.Walk(func(path []int, part *imap.BodyStructure) bool { + if !strings.EqualFold(part.MIMEType, "text") { + return true + } + if part.Disposition != "" && !strings.EqualFold(part.Disposition, "inline") { + return true + } + + if part.MIMESubType == "html" { + best = newIMAPPartNode(msg, path, part) + } + return true + }) + + return best +} + func (msg *IMAPMessage) Attachments() []IMAPPartNode { if msg.BodyStructure == nil { return nil |