aboutsummaryrefslogtreecommitdiffstats
path: root/worker/notmuch
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-01-25 08:25:51 -0500
committerRobin Jarry <robin@jarry.cc>2024-01-26 21:36:15 +0100
commit11b035f120969758d1b08dddd761f9375504de55 (patch)
treebf028d7155ceb45deba3461cb73ed74413f3d965 /worker/notmuch
parent0aab8ac318f6dee479afba13d09a5d1d1c0baa91 (diff)
downloadaerc-11b035f120969758d1b08dddd761f9375504de55.tar.gz
flags: add support for draft flag
Support the draft flag wherever flags are used. Automatically set it when postponing a message, and allow recalling a message without the -f flag if it has the draft flag set, regardless of what folder it's in. Notmuch doesn't seem to pick up on the draft flag when indexing even though the flag is set on the maildir file. Explicitly set all tags corresponding to set flags when appending a message in notmuch. Changelog-added: Support the `draft` flag. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/notmuch')
-rw-r--r--worker/notmuch/notmuch.go3
-rw-r--r--worker/notmuch/worker.go27
2 files changed, 29 insertions, 1 deletions
diff --git a/worker/notmuch/notmuch.go b/worker/notmuch/notmuch.go
index 5610cac0..1d064fd2 100644
--- a/worker/notmuch/notmuch.go
+++ b/worker/notmuch/notmuch.go
@@ -8,17 +8,20 @@ import "git.sr.ht/~rjarry/aerc/models"
var tagToFlag = map[string]models.Flags{
"unread": models.SeenFlag,
"replied": models.AnsweredFlag,
+ "draft": models.DraftFlag,
"flagged": models.FlaggedFlag,
}
var flagToTag = map[models.Flags]string{
models.SeenFlag: "unread",
models.AnsweredFlag: "replied",
+ models.DraftFlag: "draft",
models.FlaggedFlag: "flagged",
}
var flagToInvert = map[models.Flags]bool{
models.SeenFlag: true,
models.AnsweredFlag: false,
+ models.DraftFlag: false,
models.FlaggedFlag: false,
}
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index 374a20b7..80a8d720 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -894,9 +894,16 @@ func (w *worker) handleAppendMessage(msg *types.AppendMessage) error {
return err
}
writer.Close()
- if _, err := w.db.IndexFile(filename); err != nil {
+ id, err := w.db.IndexFile(filename)
+ if err != nil {
return err
}
+
+ err = w.addFlags(id, msg.Flags)
+ if err != nil {
+ return err
+ }
+
w.w.PostMessage(&types.DirectoryInfo{
Info: w.getDirectoryInfo(w.currentQueryName, w.query),
}, nil)
@@ -973,3 +980,21 @@ func (w *worker) processNewMaildirFiles(dir string) error {
return nil
}
+
+func (w *worker) addFlags(id string, flags models.Flags) error {
+ addTags := []string{}
+ removeTags := []string{}
+ for flag, tag := range flagToTag {
+ if !flags.Has(flag) {
+ continue
+ }
+
+ if flagToInvert[flag] {
+ removeTags = append(removeTags, tag)
+ } else {
+ addTags = append(addTags, tag)
+ }
+ }
+
+ return w.db.MsgModifyTags(id, addTags, removeTags)
+}