aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir
diff options
context:
space:
mode:
authorinwit <inwit@sindominio.net>2024-06-29 17:14:27 +0200
committerRobin Jarry <robin@jarry.cc>2024-08-20 11:54:34 +0200
commit93207b733046f7fde645b68f4bafd1cab51b3dff (patch)
tree121efc38a04265efb29ef42d1895b6778e152b68 /worker/maildir
parent5cf387e2cb9876b9fe5e9c7dde6f7a8ad5e7137e (diff)
downloadaerc-93207b733046f7fde645b68f4bafd1cab51b3dff.tar.gz
maildir: set the forwarded flag when forwarding msgs
The maildir backend was ignoring the passed/forwarded flag. Allow for this flag to be set and synced to the server (if the server admits it). Changelog-added: The maildir backend now honors the forwarded/passed flag. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/maildir')
-rw-r--r--worker/maildir/message.go6
-rw-r--r--worker/maildir/worker.go23
2 files changed, 29 insertions, 0 deletions
diff --git a/worker/maildir/message.go b/worker/maildir/message.go
index 6bc54cac..1d8d26b9 100644
--- a/worker/maildir/message.go
+++ b/worker/maildir/message.go
@@ -62,6 +62,12 @@ func (m Message) SetOneFlag(flag maildir.Flag, enable bool) error {
return m.SetFlags(newFlags)
}
+// MarkForwarded either adds or removes the maildir.FlagForwarded flag
+// from the message.
+func (m Message) MarkForwarded(forwarded bool) error {
+ return m.SetOneFlag(maildir.FlagPassed, forwarded)
+}
+
// MarkReplied either adds or removes the maildir.FlagReplied flag from the
// message.
func (m Message) MarkReplied(answered bool) error {
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index 7ff5093d..2c5bc893 100644
--- a/worker/maildir/worker.go
+++ b/worker/maildir/worker.go
@@ -317,6 +317,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.CopyMessages:
return w.handleCopyMessages(msg)
case *types.MoveMessages:
@@ -782,6 +784,27 @@ 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.c.Message(*w.selected, uid)
+ if err != nil {
+ w.worker.Errorf("could not get message: %v", err)
+ w.err(msg, err)
+ continue
+ }
+ if err := m.MarkForwarded(msg.Forwarded); err != nil {
+ w.worker.Errorf("could not mark message as answered: %v", err)
+ w.err(msg, err)
+ continue
+ }
+
+ w.worker.PostMessage(&types.DirectoryInfo{
+ Info: w.getDirectoryInfo(w.selectedName),
+ }, nil)
+ }
+ return nil
+}
+
func (w *Worker) handleFlagMessages(msg *types.FlagMessages) error {
for _, uid := range msg.Uids {
m, err := w.c.Message(*w.selected, uid)