summaryrefslogtreecommitdiff
path: root/worker/imap/flags.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-06-09 14:55:34 -0400
committerDrew DeVault <sir@cmpwn.com>2019-06-09 14:55:42 -0400
commit6271d455eb7d72ca2942e3721721be54fed27779 (patch)
treef5c37e55333f2fb1807b6a41fc6093838a134adc /worker/imap/flags.go
parent05f00f0153066b9bb527773927a3244dad28ef4f (diff)
downloadaerc-6271d455eb7d72ca2942e3721721be54fed27779.zip
Add :read and :unread commands
Diffstat (limited to 'worker/imap/flags.go')
-rw-r--r--worker/imap/flags.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/worker/imap/flags.go b/worker/imap/flags.go
index bd368c1..0122d8e 100644
--- a/worker/imap/flags.go
+++ b/worker/imap/flags.go
@@ -41,3 +41,20 @@ func (imapw *IMAPWorker) handleDeleteMessages(msg *types.DeleteMessages) {
imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
}
}
+
+func (imapw *IMAPWorker) handleReadMessages(msg *types.ReadMessages) {
+ item := imap.FormatFlagsOp(imap.AddFlags, true)
+ flags := []interface{}{imap.SeenFlag}
+ if !msg.Read {
+ item = imap.FormatFlagsOp(imap.RemoveFlags, true)
+ flags = []interface{}{imap.SeenFlag}
+ }
+ if err := imapw.client.UidStore(&msg.Uids, item, flags, nil); err != nil {
+ imapw.worker.PostMessage(&types.Error{
+ Message: types.RespondTo(msg),
+ Error: err,
+ }, nil)
+ return
+ }
+ imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
+}