aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/imap.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/imap.go')
-rwxr-xr-xplugins/base/imap.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/base/imap.go b/plugins/base/imap.go
index eadb098..177fefc 100755
--- a/plugins/base/imap.go
+++ b/plugins/base/imap.go
@@ -180,6 +180,33 @@ func (msg *IMAPMessage) Attachments() []IMAPPartNode {
return attachments
}
+func pathsEqual(a, b []int) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ for i := range a {
+ if a[i] != b[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func (msg *IMAPMessage) PartByPath(path []int) *IMAPPartNode {
+ if msg.BodyStructure == nil {
+ return nil
+ }
+
+ var result *IMAPPartNode
+ msg.BodyStructure.Walk(func(p []int, part *imap.BodyStructure) bool {
+ if result == nil && pathsEqual(path, p) {
+ result = newIMAPPartNode(msg, p, part)
+ }
+ return result == nil
+ })
+ return result
+}
+
func (msg *IMAPMessage) PartByID(id string) *IMAPPartNode {
if msg.BodyStructure == nil || id == "" {
return nil