aboutsummaryrefslogtreecommitdiffstats
path: root/worker/jmap
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2024-02-01 23:52:55 +0100
committerRobin Jarry <robin@jarry.cc>2024-02-11 22:03:56 +0100
commite7c26e02bb326f08c071e9f37ebf80952a0cca97 (patch)
treeb20503b2df2b1fafd751aa7abc998fca24fa66a4 /worker/jmap
parent05874f867c76c8e9b8c1e67a57dc702e63d6d54b (diff)
downloadaerc-e7c26e02bb326f08c071e9f37ebf80952a0cca97.tar.gz
filter: allow workers to combine filter terms
Allow the backend workers to combine the filter terms. Currently, the consecutive filters are joined in the message store with a space (" "). This works well for most backends, but makes the filter combination for notmuch confusing. Example: Issuing two consecutive filter commands in notmuch :filter not tag:list :filter tag:list would create the following filter query 'not tag:list tag:list' This is not what users would expect; they expect: '(not tag:list) and (tag:list)' Note that the notmuch backend works correctly for the given query, but produced a query that does not match the user's expectation. This patch fixes this. The combination of filter terms in other backends remains the same. Reported-by: Ángel Castañeda <angel@acsq.me> Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/jmap')
-rw-r--r--worker/jmap/search.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/worker/jmap/search.go b/worker/jmap/search.go
index 0101ce9b..024cc181 100644
--- a/worker/jmap/search.go
+++ b/worker/jmap/search.go
@@ -1,6 +1,8 @@
package jmap
import (
+ "strings"
+
"git.sr.ht/~rjarry/aerc/worker/types"
"git.sr.ht/~rockorager/go-jmap"
"git.sr.ht/~rockorager/go-jmap/mail/email"
@@ -38,13 +40,14 @@ func (w *JMAPWorker) translateSearch(
}
// general search terms
+ terms := strings.Join(criteria.Terms, " ")
switch {
case criteria.SearchAll:
- cond.Text = criteria.Terms
+ cond.Text = terms
case criteria.SearchBody:
- cond.Body = criteria.Terms
+ cond.Body = terms
default:
- cond.Subject = criteria.Terms
+ cond.Subject = terms
}
filter := &email.FilterOperator{Operator: jmap.OperatorAND}