diff options
author | Srivathsan Murali <sri@vathsan.com> | 2020-05-25 16:59:48 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-05-25 11:29:53 -0400 |
commit | b1eb7ad18d2e0bbeecaf61a58825bbc794ceb40c (patch) | |
tree | 310ff7fa90dfb23c303b7f89674b8411bd8cdf89 /worker/maildir/worker.go | |
parent | a31d184ba53a9a61b8a0eed42cee52f9b1f2dc51 (diff) | |
download | aerc-b1eb7ad18d2e0bbeecaf61a58825bbc794ceb40c.tar.gz |
Set AnsweredFlag on successful reply
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r-- | worker/maildir/worker.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index dbdb925..f14672e 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -195,6 +195,8 @@ func (w *Worker) handleMessage(msg types.WorkerMessage) error { return w.handleDeleteMessages(msg) case *types.ReadMessages: return w.handleReadMessages(msg) + case *types.AnsweredMessages: + return w.handleAnsweredMessages(msg) case *types.CopyMessages: return w.handleCopyMessages(msg) case *types.AppendMessage: @@ -438,6 +440,39 @@ func (w *Worker) handleDeleteMessages(msg *types.DeleteMessages) error { return nil } +func (w *Worker) handleAnsweredMessages(msg *types.AnsweredMessages) error { + for _, uid := range msg.Uids { + m, err := w.c.Message(*w.selected, uid) + if err != nil { + w.worker.Logger.Printf("could not get message: %v", err) + w.err(msg, err) + continue + } + if err := m.MarkReplied(msg.Answered); err != nil { + w.worker.Logger.Printf( + "could not mark message as answered: %v", err) + w.err(msg, err) + continue + } + info, err := m.MessageInfo() + if err != nil { + w.worker.Logger.Printf("could not get message info: %v", err) + w.err(msg, err) + continue + } + + w.worker.PostMessage(&types.MessageInfo{ + Message: types.RespondTo(msg), + Info: info, + }, nil) + + w.worker.PostMessage(&types.DirectoryInfo{ + Info: w.getDirectoryInfo(w.selectedName), + }, nil) + } + return nil +} + func (w *Worker) handleReadMessages(msg *types.ReadMessages) error { for _, uid := range msg.Uids { m, err := w.c.Message(*w.selected, uid) |