aboutsummaryrefslogtreecommitdiffstats
path: root/worker/notmuch/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/notmuch/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/notmuch/worker.go')
-rw-r--r--worker/notmuch/worker.go20
1 files changed, 3 insertions, 17 deletions
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index 2f601528..486312a1 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -531,13 +531,7 @@ func (w *worker) handleFlagMessages(msg *types.FlagMessages) error {
}
func (w *worker) handleSearchDirectory(msg *types.SearchDirectory) error {
- // the first item is the command (:search)
- log.Debugf("search args: %v", msg.Argv)
- s, err := translate(msg.Argv)
- if err != nil {
- log.Debugf("ERROR: %v", err)
- return err
- }
+ s := translate(msg.Criteria)
// we only want to search in the current query, so merge the two together
search := w.query
if s != "" {
@@ -605,11 +599,7 @@ func (w *worker) emitDirectoryContents(parent types.WorkerMessage) error {
query := w.query
ctx := context.Background()
if msg, ok := parent.(*types.FetchDirectoryContents); ok {
- log.Debugf("filter input: '%v'", msg.FilterCriteria)
- s, err := translate(msg.FilterCriteria)
- if err != nil {
- return err
- }
+ s := translate(msg.Filter)
if s != "" {
query = fmt.Sprintf("(%v) and (%v)", query, s)
log.Debugf("filter query: '%s'", query)
@@ -637,11 +627,7 @@ func (w *worker) emitDirectoryThreaded(parent types.WorkerMessage) error {
ctx := context.Background()
threadContext := false
if msg, ok := parent.(*types.FetchDirectoryThreaded); ok {
- log.Debugf("filter input: '%v'", msg.FilterCriteria)
- s, err := translate(msg.FilterCriteria)
- if err != nil {
- return err
- }
+ s := translate(msg.Filter)
if s != "" {
query = fmt.Sprintf("(%v) and (%v)", query, s)
log.Debugf("filter query: '%s'", query)