diff options
Diffstat (limited to 'worker')
-rw-r--r-- | worker/imap/fetch.go | 14 | ||||
-rw-r--r-- | worker/imap/flags.go | 6 | ||||
-rw-r--r-- | worker/imap/imap.go | 13 | ||||
-rw-r--r-- | worker/imap/movecopy.go | 3 | ||||
-rw-r--r-- | worker/types/messages.go | 10 |
5 files changed, 30 insertions, 16 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go index d5bb9aa..fe25977 100644 --- a/worker/imap/fetch.go +++ b/worker/imap/fetch.go @@ -31,8 +31,7 @@ func (imapw *IMAPWorker) handleFetchMessageHeaders( imap.FetchUid, section.FetchItem(), } - - imapw.handleFetchMessages(msg, &msg.Uids, items, section) + imapw.handleFetchMessages(msg, msg.Uids, items, section) } func (imapw *IMAPWorker) handleFetchMessageBodyPart( @@ -46,9 +45,7 @@ func (imapw *IMAPWorker) handleFetchMessageBodyPart( imap.FetchUid, section.FetchItem(), } - uids := imap.SeqSet{} - uids.AddNum(msg.Uid) - imapw.handleFetchMessages(msg, &uids, items, section) + imapw.handleFetchMessages(msg, []uint32{msg.Uid}, items, section) } func (imapw *IMAPWorker) handleFetchFullMessages( @@ -61,11 +58,11 @@ func (imapw *IMAPWorker) handleFetchFullMessages( imap.FetchUid, section.FetchItem(), } - imapw.handleFetchMessages(msg, &msg.Uids, items, section) + imapw.handleFetchMessages(msg, msg.Uids, items, section) } func (imapw *IMAPWorker) handleFetchMessages( - msg types.WorkerMessage, uids *imap.SeqSet, items []imap.FetchItem, + msg types.WorkerMessage, uids []uint32, items []imap.FetchItem, section *imap.BodySectionName) { messages := make(chan *imap.Message) @@ -132,7 +129,8 @@ func (imapw *IMAPWorker) handleFetchMessages( done <- nil }() - if err := imapw.client.UidFetch(uids, items, messages); err != nil { + set := toSeqSet(uids) + if err := imapw.client.UidFetch(set, items, messages); err != nil { imapw.worker.PostMessage(&types.Error{ Message: types.RespondTo(msg), Error: err, diff --git a/worker/imap/flags.go b/worker/imap/flags.go index 0122d8e..57211a6 100644 --- a/worker/imap/flags.go +++ b/worker/imap/flags.go @@ -9,7 +9,8 @@ import ( func (imapw *IMAPWorker) handleDeleteMessages(msg *types.DeleteMessages) { item := imap.FormatFlagsOp(imap.AddFlags, true) flags := []interface{}{imap.DeletedFlag} - if err := imapw.client.UidStore(&msg.Uids, item, flags, nil); err != nil { + uids := toSeqSet(msg.Uids) + if err := imapw.client.UidStore(uids, item, flags, nil); err != nil { imapw.worker.PostMessage(&types.Error{ Message: types.RespondTo(msg), Error: err, @@ -49,7 +50,8 @@ func (imapw *IMAPWorker) handleReadMessages(msg *types.ReadMessages) { item = imap.FormatFlagsOp(imap.RemoveFlags, true) flags = []interface{}{imap.SeenFlag} } - if err := imapw.client.UidStore(&msg.Uids, item, flags, nil); err != nil { + uids := toSeqSet(msg.Uids) + if err := imapw.client.UidStore(uids, item, flags, nil); err != nil { imapw.worker.PostMessage(&types.Error{ Message: types.RespondTo(msg), Error: err, diff --git a/worker/imap/imap.go b/worker/imap/imap.go new file mode 100644 index 0000000..28bac93 --- /dev/null +++ b/worker/imap/imap.go @@ -0,0 +1,13 @@ +package imap + +import ( + "github.com/emersion/go-imap" +) + +func toSeqSet(uids []uint32) *imap.SeqSet { + var set imap.SeqSet + for _, uid := range uids { + set.AddNum(uid) + } + return &set +} diff --git a/worker/imap/movecopy.go b/worker/imap/movecopy.go index 6cf3fe1..b01dab7 100644 --- a/worker/imap/movecopy.go +++ b/worker/imap/movecopy.go @@ -7,7 +7,8 @@ import ( ) func (imapw *IMAPWorker) handleCopyMessages(msg *types.CopyMessages) { - if err := imapw.client.UidCopy(&msg.Uids, msg.Destination); err != nil { + uids := toSeqSet(msg.Uids) + if err := imapw.client.UidCopy(uids, msg.Destination); err != nil { imapw.worker.PostMessage(&types.Error{ Message: types.RespondTo(msg), Error: err, diff --git a/worker/types/messages.go b/worker/types/messages.go index bb2505a..bab14e0 100644 --- a/worker/types/messages.go +++ b/worker/types/messages.go @@ -94,12 +94,12 @@ type CreateDirectory struct { type FetchMessageHeaders struct { Message - Uids imap.SeqSet + Uids []uint32 } type FetchFullMessages struct { Message - Uids imap.SeqSet + Uids []uint32 } type FetchMessageBodyPart struct { @@ -110,20 +110,20 @@ type FetchMessageBodyPart struct { type DeleteMessages struct { Message - Uids imap.SeqSet + Uids []uint32 } // Marks messages as read or unread type ReadMessages struct { Message Read bool - Uids imap.SeqSet + Uids []uint32 } type CopyMessages struct { Message Destination string - Uids imap.SeqSet + Uids []uint32 } type AppendMessage struct { |