about summary refs log tree commit diff stats
path: root/worker/imap
diff options
context:
space:
mode:
authorARaspiK <araspik@protonmail.com>2020-07-05 14:29:52 +0000
committerReto Brunner <reto@labrat.space>2020-07-08 09:13:03 +0200
commit0535f6333f2f5d13469fc315a65c53ff8a5e83f3 (patch)
treefa3adf96b16d4a0296c04b6a17f5433c03fbc8de /worker/imap
parentfda3f43e7c5e5a175a01dd3e5b8637b1ecb30c51 (diff)
downloadaerc-0535f6333f2f5d13469fc315a65c53ff8a5e83f3.tar.gz
Add additional flagging functionality
More mail flags can now be set, unset, and toggled, not just the
read/seen flag.

This functionality is implemented with a new `:flag` and `:unflag`
command, which are extensions to the matching `:read` and `:unread`
commands, adding support for different flags.  In fact, the
`read`/`unread` commands are now recognized aliases to `flag`/`unflag`.
The new commands are also well documented in aerc(1).

The change mostly extends the previous read/unread setting functionality
by adding a selection for the flag to change.
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/flags.go9
-rw-r--r--worker/imap/worker.go4
2 files changed, 6 insertions, 7 deletions
diff --git a/worker/imap/flags.go b/worker/imap/flags.go
index 2625086..aef1019 100644
--- a/worker/imap/flags.go
+++ b/worker/imap/flags.go
@@ -76,12 +76,11 @@ func (imapw *IMAPWorker) handleAnsweredMessages(msg *types.AnsweredMessages) {
 	})
 }
 
-func (imapw *IMAPWorker) handleReadMessages(msg *types.ReadMessages) {
+func (imapw *IMAPWorker) handleFlagMessages(msg *types.FlagMessages) {
+	flags := []interface{}{flagToImap[msg.Flag]}
 	item := imap.FormatFlagsOp(imap.AddFlags, true)
-	flags := []interface{}{imap.SeenFlag}
-	if !msg.Read {
+	if !msg.Enable {
 		item = imap.FormatFlagsOp(imap.RemoveFlags, true)
-		flags = []interface{}{imap.SeenFlag}
 	}
 	uids := toSeqSet(msg.Uids)
 	emitErr := func(err error) {
@@ -99,7 +98,7 @@ func (imapw *IMAPWorker) handleReadMessages(msg *types.ReadMessages) {
 	}, func(_msg types.WorkerMessage) {
 		switch m := _msg.(type) {
 		case *types.Error:
-			err := fmt.Errorf("handleReadMessages: %v", m.Error)
+			err := fmt.Errorf("handleFlagMessages: %v", m.Error)
 			imapw.worker.Logger.Printf("could not fetch headers: %s", err)
 			emitErr(err)
 		case *types.Done:
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index a43ac49..0be51d7 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -173,8 +173,8 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
 		w.handleFetchFullMessages(msg)
 	case *types.DeleteMessages:
 		w.handleDeleteMessages(msg)
-	case *types.ReadMessages:
-		w.handleReadMessages(msg)
+	case *types.FlagMessages:
+		w.handleFlagMessages(msg)
 	case *types.AnsweredMessages:
 		w.handleAnsweredMessages(msg)
 	case *types.CopyMessages: