aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir/worker.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-10-17 15:31:09 +0200
committerRobin Jarry <robin@jarry.cc>2023-10-28 19:24:59 +0200
commit8464b373851142b0becaaa10db34df3559b2b62e (patch)
treedd785d6c717f1e620c63252348d8add991587a57 /worker/maildir/worker.go
parent57088312fdd8e602a084bd5736a0e22a34be9ec0 (diff)
downloadaerc-8464b373851142b0becaaa10db34df3559b2b62e.tar.gz
search: use a common api for all workers
Define a SearchCriteria structure. Update the FetchDirectoryContents, FetchDirectoryThreaded and SearchDirectory worker messages to include this SearchCriteria structure instead of a []string slice. Parse the search arguments in a single place into a SearchCriteria structure and use it to search/filter via the message store. Update all workers to use that new API. Clarify the man page indicating that notmuch supports searching with aerc's syntax and also with notmuch specific syntax. getopt is no longer needed, remove it from go.mod. NB: to support more complex search filters in JMAP, we need to use an email.Filter interface. Since GOB does not support encoding/decoding interfaces, store the raw SearchCriteria and []SortCriterion values in the cached FolderContents. Translate them to JMAP API objects when sending an email.Query request to the server. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r--worker/maildir/worker.go26
1 files changed, 6 insertions, 20 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index 0be6137f..f843d002 100644
--- a/worker/maildir/worker.go
+++ b/worker/maildir/worker.go
@@ -461,13 +461,8 @@ func (w *Worker) handleFetchDirectoryContents(
uids []uint32
err error
)
- // FilterCriteria always contains "filter" as first item
- if len(msg.FilterCriteria) > 1 {
- filter, err := parseSearch(msg.FilterCriteria)
- if err != nil {
- return err
- }
- uids, err = w.search(msg.Context, filter)
+ if msg.Filter != nil {
+ uids, err = w.search(msg.Context, msg.Filter)
if err != nil {
return err
}
@@ -546,12 +541,8 @@ func (w *Worker) handleFetchDirectoryThreaded(
uids []uint32
err error
)
- if len(msg.FilterCriteria) > 1 {
- filter, err := parseSearch(msg.FilterCriteria)
- if err != nil {
- return err
- }
- uids, err = w.search(msg.Context, filter)
+ if msg.Filter != nil {
+ uids, err = w.search(msg.Context, msg.Filter)
if err != nil {
return err
}
@@ -871,13 +862,8 @@ func (w *Worker) handleAppendMessage(msg *types.AppendMessage) error {
}
func (w *Worker) handleSearchDirectory(msg *types.SearchDirectory) error {
- w.worker.Debugf("Searching directory %v with args: %v", *w.selected, msg.Argv)
- criteria, err := parseSearch(msg.Argv)
- if err != nil {
- return err
- }
- w.worker.Tracef("Searching with parsed criteria: %#v", criteria)
- uids, err := w.search(msg.Context, criteria)
+ w.worker.Tracef("Searching with criteria: %#v", msg.Criteria)
+ uids, err := w.search(msg.Context, msg.Criteria)
if err != nil {
return err
}