aboutsummaryrefslogtreecommitdiffstats
path: root/worker/notmuch/search.go
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-01-25 08:25:49 -0500
committerRobin Jarry <robin@jarry.cc>2024-01-26 21:36:12 +0100
commit0aab8ac318f6dee479afba13d09a5d1d1c0baa91 (patch)
treef33819ffdf9ab21325a6d7b58e5d652c16a927eb /worker/notmuch/search.go
parent936d519a67301bd78a4d737dc47234e3769e639f (diff)
downloadaerc-0aab8ac318f6dee479afba13d09a5d1d1c0baa91.tar.gz
notmuch: centralize flag/tag mappings
Mimic other backends that have centralized mappings. Doing so makes adding support for the draft flag simpler in a subsequent commit. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/notmuch/search.go')
-rw-r--r--worker/notmuch/search.go15
1 files changed, 3 insertions, 12 deletions
diff --git a/worker/notmuch/search.go b/worker/notmuch/search.go
index b3592d41..36d4c2df 100644
--- a/worker/notmuch/search.go
+++ b/worker/notmuch/search.go
@@ -67,7 +67,7 @@ func translate(crit *types.SearchCriteria) string {
}
// flags
- for _, f := range []models.Flags{models.SeenFlag, models.AnsweredFlag, models.FlaggedFlag} {
+ for f := range flagToTag {
if crit.WithFlags.Has(f) {
base.and(getParsedFlag(f, false))
}
@@ -100,17 +100,8 @@ func translate(crit *types.SearchCriteria) string {
}
func getParsedFlag(flag models.Flags, inverse bool) string {
- name := ""
- switch flag {
- case models.AnsweredFlag:
- name = "tag:replied"
- case models.SeenFlag:
- name = "tag:unread"
- inverse = !inverse
- case models.FlaggedFlag:
- name = "tag:flagged"
- }
- if inverse {
+ name := "tag:" + flagToTag[flag]
+ if flagToInvert[flag] {
name = "not " + name
}
return name