aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/imap.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/imap.go')
-rw-r--r--plugins/base/imap.go27
1 files changed, 1 insertions, 26 deletions
diff --git a/plugins/base/imap.go b/plugins/base/imap.go
index 6c3f33f..3492e7e 100644
--- a/plugins/base/imap.go
+++ b/plugins/base/imap.go
@@ -399,37 +399,12 @@ func listMessages(conn *imapclient.Client, mbox *MailboxStatus, page, messagesPe
return msgs, nil
}
-func searchCriteriaHeader(k, v string) *imap.SearchCriteria {
- return &imap.SearchCriteria{
- Header: map[string][]string{
- k: []string{v},
- },
- }
-}
-
-func searchCriteriaOr(criteria ...*imap.SearchCriteria) *imap.SearchCriteria {
- or := criteria[0]
- for _, c := range criteria[1:] {
- or = &imap.SearchCriteria{
- Or: [][2]*imap.SearchCriteria{{or, c}},
- }
- }
- return or
-}
-
func searchMessages(conn *imapclient.Client, mboxName, query string, page, messagesPerPage int) (msgs []IMAPMessage, total int, err error) {
if err := ensureMailboxSelected(conn, mboxName); err != nil {
return nil, 0, err
}
- // TODO: full-text search on demand (can be slow)
- //criteria := &imap.SearchCriteria{Text: []string{query}}
- criteria := searchCriteriaOr(
- searchCriteriaHeader("From", query),
- searchCriteriaHeader("To", query),
- searchCriteriaHeader("Cc", query),
- searchCriteriaHeader("Subject", query),
- )
+ criteria := PrepareSearch(query)
nums, err := conn.Search(criteria)
if err != nil {
return nil, 0, fmt.Errorf("UID SEARCH failed: %v", err)