aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinwit <inwit@sindominio.net>2024-06-29 17:14:26 +0200
committerRobin Jarry <robin@jarry.cc>2024-08-20 11:54:34 +0200
commit5cf387e2cb9876b9fe5e9c7dde6f7a8ad5e7137e (patch)
treef7c0fb2446b0f015d034d0054b008a5f1dacc2cc
parent4f114577908dd744555c023cccee273f76d3c73d (diff)
downloadaerc-5cf387e2cb9876b9fe5e9c7dde6f7a8ad5e7137e.tar.gz
notmuch: set the "passed" tag when forwarding msgs
In notmuch, forwarded messages should be marked with the "passed" tag, which is subsequently synchronized with the corresponding maildir "P" flag. Ensure both flag and tag are applied to forwarded messages in the notmuch interface. Link: https://notmuchmail.org/special-tags/ Changelog-added: The notmuch backend now honors the forwarded flag, setting the "passed" tag. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--worker/notmuch/message.go5
-rw-r--r--worker/notmuch/notmuch.go19
-rw-r--r--worker/notmuch/worker.go20
3 files changed, 36 insertions, 8 deletions
diff --git a/worker/notmuch/message.go b/worker/notmuch/message.go
index b73f1888..539d85ae 100644
--- a/worker/notmuch/message.go
+++ b/worker/notmuch/message.go
@@ -116,6 +116,11 @@ func (m *Message) MarkAnswered(answered bool) error {
return m.SetFlag(models.AnsweredFlag, answered)
}
+// MarkForwarded either adds or removes the "forwarded" tag from the message.
+func (m *Message) MarkForwarded(forwarded bool) error {
+ return m.SetFlag(models.ForwardedFlag, forwarded)
+}
+
// MarkRead either adds or removes the maildir.FlagSeen flag from the message.
func (m *Message) MarkRead(seen bool) error {
return m.SetFlag(models.SeenFlag, seen)
diff --git a/worker/notmuch/notmuch.go b/worker/notmuch/notmuch.go
index 1d064fd2..854abb6e 100644
--- a/worker/notmuch/notmuch.go
+++ b/worker/notmuch/notmuch.go
@@ -8,20 +8,23 @@ import "git.sr.ht/~rjarry/aerc/models"
var tagToFlag = map[string]models.Flags{
"unread": models.SeenFlag,
"replied": models.AnsweredFlag,
+ "passed": models.ForwardedFlag,
"draft": models.DraftFlag,
"flagged": models.FlaggedFlag,
}
var flagToTag = map[models.Flags]string{
- models.SeenFlag: "unread",
- models.AnsweredFlag: "replied",
- models.DraftFlag: "draft",
- models.FlaggedFlag: "flagged",
+ models.SeenFlag: "unread",
+ models.AnsweredFlag: "replied",
+ models.ForwardedFlag: "passed",
+ models.DraftFlag: "draft",
+ models.FlaggedFlag: "flagged",
}
var flagToInvert = map[models.Flags]bool{
- models.SeenFlag: true,
- models.AnsweredFlag: false,
- models.DraftFlag: false,
- models.FlaggedFlag: false,
+ models.SeenFlag: true,
+ models.AnsweredFlag: false,
+ models.ForwardedFlag: false,
+ models.DraftFlag: false,
+ models.FlaggedFlag: false,
}
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index c6a81050..f3a9ce8b 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -182,6 +182,8 @@ func (w *worker) handleMessage(msg types.WorkerMessage) error {
return w.handleFlagMessages(msg)
case *types.AnsweredMessages:
return w.handleAnsweredMessages(msg)
+ case *types.ForwardedMessages:
+ return w.handleForwardedMessages(msg)
case *types.SearchDirectory:
return w.handleSearchDirectory(msg)
case *types.ModifyLabels:
@@ -545,6 +547,24 @@ func (w *worker) handleAnsweredMessages(msg *types.AnsweredMessages) error {
return nil
}
+func (w *worker) handleForwardedMessages(msg *types.ForwardedMessages) error {
+ for _, uid := range msg.Uids {
+ m, err := w.msgFromUid(uid)
+ if err != nil {
+ w.w.Errorf("could not get message: %v", err)
+ w.err(msg, err)
+ continue
+ }
+ if err := m.MarkForwarded(msg.Forwarded); err != nil {
+ w.w.Errorf("could not mark message as forwarded: %v", err)
+ w.err(msg, err)
+ continue
+ }
+ }
+ w.done(msg)
+ return nil
+}
+
func (w *worker) handleFlagMessages(msg *types.FlagMessages) error {
for _, uid := range msg.Uids {
m, err := w.msgFromUid(uid)