diff options
author | Jeffas <dev@jeffas.io> | 2019-09-14 18:05:20 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-09-16 12:40:26 -0400 |
commit | c97d0d6320de996f00e5562c487059950423c151 (patch) | |
tree | 0dad188733eaed1b4a2d972cbb2ff5ddd61df3d4 /worker/maildir/worker.go | |
parent | edfab1b201c86a14d825ca02a82f5c7ec3eb5911 (diff) | |
download | aerc-c97d0d6320de996f00e5562c487059950423c151.tar.gz |
Add basic searching to the maildir backend
Basic searching is supported with the following: - read messages - unread messages - from addresses - text in body - text in subject - text in all The implementation loops through all messages in the selected directory. It tries to be smart by detecting which parts of each message the search query needs to use and only loads these from the filesystem.
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r-- | worker/maildir/worker.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index 533bb7c..3e59da6 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -407,5 +407,19 @@ func (w *Worker) handleAppendMessage(msg *types.AppendMessage) error { } func (w *Worker) handleSearchDirectory(msg *types.SearchDirectory) error { - return errUnsupported + w.worker.Logger.Printf("Searching directory %v with args: %v", *w.selected, msg.Argv) + criteria, err := parseSearch(msg.Argv) + if err != nil { + return err + } + w.worker.Logger.Printf("Searching with parsed criteria: %#v", criteria) + uids, err := w.search(criteria) + if err != nil { + return err + } + w.worker.PostMessage(&types.SearchResults{ + Message: types.RespondTo(msg), + Uids: uids, + }, nil) + return nil } |