diff options
Diffstat (limited to 'worker/imap')
-rw-r--r-- | worker/imap/movecopy.go | 27 | ||||
-rw-r--r-- | worker/imap/worker.go | 4 |
2 files changed, 31 insertions, 0 deletions
diff --git a/worker/imap/movecopy.go b/worker/imap/movecopy.go index 8c42a2eb..1234e602 100644 --- a/worker/imap/movecopy.go +++ b/worker/imap/movecopy.go @@ -1,6 +1,8 @@ package imap import ( + "io" + "git.sr.ht/~sircmpwn/aerc2/worker/types" ) @@ -14,3 +16,28 @@ func (imapw *IMAPWorker) handleCopyMessages(msg *types.CopyMessages) { imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil) } } + +type appendLiteral struct { + io.Reader + Length int +} + +func (m appendLiteral) Len() int { + return m.Length +} + +func (imapw *IMAPWorker) handleAppendMessage(msg *types.AppendMessage) { + if err := imapw.client.Append(msg.Destination, msg.Flags, msg.Date, + &appendLiteral{ + Reader: msg.Reader, + Length: msg.Length, + }); err != nil { + + imapw.worker.PostMessage(&types.Error{ + Message: types.RespondTo(msg), + Error: err, + }, nil) + } else { + imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil) + } +} diff --git a/worker/imap/worker.go b/worker/imap/worker.go index 1fab3bbf..5dce18e0 100644 --- a/worker/imap/worker.go +++ b/worker/imap/worker.go @@ -153,6 +153,8 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error { } } + c.SetDebug(w.worker.Logger.Writer()) + if _, err := c.Select(imap.InboxName, false); err != nil { return err } @@ -176,6 +178,8 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error { w.handleDeleteMessages(msg) case *types.CopyMessages: w.handleCopyMessages(msg) + case *types.AppendMessage: + w.handleAppendMessage(msg) default: return errUnsupported } |