From 6271d455eb7d72ca2942e3721721be54fed27779 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 9 Jun 2019 14:55:34 -0400 Subject: Add :read and :unread commands --- worker/imap/flags.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'worker/imap/flags.go') diff --git a/worker/imap/flags.go b/worker/imap/flags.go index bd368c11..0122d8e5 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) +} -- cgit