From c97d0d6320de996f00e5562c487059950423c151 Mon Sep 17 00:00:00 2001 From: Jeffas Date: Sat, 14 Sep 2019 18:05:20 +0100 Subject: 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. --- worker/maildir/worker.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'worker/maildir/worker.go') 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 } -- cgit v1.2.3