From 64b16f4a5039bee9a97d3c69db0b49c5a9217908 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 23 Oct 2020 15:15:46 -0400 Subject: message.html: add tabs to select html/plaintext --- plugins/base/imap.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'plugins/base/imap.go') 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 -- cgit v1.2.3