diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-07-05 14:48:40 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-10 21:15:12 +0200 |
commit | c2f4404fca15be37228545b1893f5fa335168337 (patch) | |
tree | 2bfc788a7e38510f1d5057c4b47d2460a548cb44 /worker/notmuch/worker.go | |
parent | ccd042889f6d8aa78b70c01395ef69aec48ac48c (diff) | |
download | aerc-c2f4404fca15be37228545b1893f5fa335168337.tar.gz |
threading: enable filtering of server-side threads
This patch enables the filtering of a threaded view which uses
server-built threads. Filtering is done server-side, in order to
preserve the use of server-built threads.
In adding this feature, the filtering of notmuch folders was brought up
to feature parity with the other workers. The filters function the same
(ie: they can be stacked). The notmuch filters, however, still use
notmuch syntax for the filtering.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/notmuch/worker.go')
-rw-r--r-- | worker/notmuch/worker.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index 35e68409..27be73db 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -550,7 +550,14 @@ func (w *worker) loadExcludeTags( } func (w *worker) emitDirectoryContents(parent types.WorkerMessage) error { - uids, err := w.uidsFromQuery(w.query) + query := w.query + if msg, ok := parent.(*types.FetchDirectoryContents); ok { + s := strings.Join(msg.FilterCriteria[1:], " ") + if s != "" { + query = fmt.Sprintf("(%v) and (%v)", query, s) + } + } + uids, err := w.uidsFromQuery(query) if err != nil { return fmt.Errorf("could not fetch uids: %v", err) } @@ -567,12 +574,18 @@ func (w *worker) emitDirectoryContents(parent types.WorkerMessage) error { } func (w *worker) emitDirectoryThreaded(parent types.WorkerMessage) error { - threads, err := w.db.ThreadsFromQuery(w.query) + query := w.query + if msg, ok := parent.(*types.FetchDirectoryThreaded); ok { + s := strings.Join(msg.FilterCriteria[1:], " ") + if s != "" { + query = fmt.Sprintf("(%v) and (%v)", query, s) + } + } + threads, err := w.db.ThreadsFromQuery(query) if err != nil { return err } w.w.PostMessage(&types.DirectoryThreaded{ - Message: types.RespondTo(parent), Threads: threads, }, nil) return nil |