diff options
author | 2020-11-13 12:19:46 -0500 | |
---|---|---|
committer | 2020-11-13 12:19:46 -0500 | |
commit | 6ecb243620c6114cc5b25ec780aff9040ac49260 (patch) | |
tree | 96abdd2a9b12da3c4ba82224294ccef7f1123ccd /plugins/base/imap.go | |
parent | 1321cea241e0fa3f3ac7da38b7364b46e0858f11 (diff) | |
download | alps-6ecb243620c6114cc5b25ec780aff9040ac49260.tar.gz alps-6ecb243620c6114cc5b25ec780aff9040ac49260.tar.bz2 alps-6ecb243620c6114cc5b25ec780aff9040ac49260.zip |
Fix duplicate drafts on repeated saves
Diffstat (limited to 'plugins/base/imap.go')
-rw-r--r-- | plugins/base/imap.go | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/plugins/base/imap.go b/plugins/base/imap.go index f15105c..64b3164 100644 --- a/plugins/base/imap.go +++ b/plugins/base/imap.go @@ -9,7 +9,6 @@ import ( "strconv" "strings" "time" - nettextproto "net/textproto" "github.com/dustin/go-humanize" "github.com/emersion/go-imap" @@ -571,20 +570,20 @@ func markMessageAnswered(conn *imapclient.Client, mboxName string, uid uint32) e return conn.UidStore(seqSet, item, flags, nil) } -func appendMessage(c *imapclient.Client, msg *OutgoingMessage, mboxType mailboxType) (*MailboxInfo, uint32, error) { +func appendMessage(c *imapclient.Client, msg *OutgoingMessage, mboxType mailboxType) (*MailboxInfo, error) { mbox, err := getMailboxByType(c, mboxType) if err != nil { - return nil, 0, err + return nil, err } if mbox == nil { - return nil, 0, fmt.Errorf("Unable to resolve mailbox") + return nil, fmt.Errorf("Unable to resolve mailbox") } // IMAP needs to know in advance the final size of the message, so // there's no way around storing it in a buffer here. var buf bytes.Buffer if err := msg.WriteTo(&buf); err != nil { - return nil, 0, err + return nil, err } flags := []string{imap.SeenFlag} @@ -592,20 +591,9 @@ func appendMessage(c *imapclient.Client, msg *OutgoingMessage, mboxType mailboxT flags = append(flags, imap.DraftFlag) } if err := c.Append(mbox.Name, flags, time.Now(), &buf); err != nil { - return nil, 0, err - } - criteria := &imap.SearchCriteria{ - Header: make(nettextproto.MIMEHeader), - } - criteria.Header.Add("Message-Id", msg.MessageID) - if uids, err := c.UidSearch(criteria); err != nil { - return nil, 0, err - } else { - if len(uids) != 1 { - panic(fmt.Errorf("Duplicate message ID")) - } - return mbox, uids[0], nil + return nil, err } + return mbox, nil } func deleteMessage(c *imapclient.Client, mboxName string, uid uint32) error { |