aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-11-15 21:24:51 +0100
committerRobin Jarry <robin@jarry.cc>2022-12-02 22:59:40 +0100
commitce7fbd27ee8f41adfa8e33002ccf965c6a917e5a (patch)
tree8681f68161b2f088678b2a73643195dc3f8106d0 /worker/imap
parent739ec7933b0b4a6aa13761759b90a33e34f24a7c (diff)
downloadaerc-ce7fbd27ee8f41adfa8e33002ccf965c6a917e5a.tar.gz
imap: filter and search with a date range
Filter and search with a date range in the imap backend. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/search.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/worker/imap/search.go b/worker/imap/search.go
index adbc6b90..ba7b9174 100644
--- a/worker/imap/search.go
+++ b/worker/imap/search.go
@@ -6,6 +6,8 @@ import (
"github.com/emersion/go-imap"
+ "git.sr.ht/~rjarry/aerc/log"
+ "git.sr.ht/~rjarry/aerc/worker/lib"
"git.sr.ht/~sircmpwn/getopt"
)
@@ -15,7 +17,7 @@ func parseSearch(args []string) (*imap.SearchCriteria, error) {
return criteria, nil
}
- opts, optind, err := getopt.Getopts(args, "rubax:X:t:H:f:c:")
+ opts, optind, err := getopt.Getopts(args, "rubax:X:t:H:f:c:d:")
if err != nil {
return nil, err
}
@@ -47,6 +49,18 @@ func parseSearch(args []string) (*imap.SearchCriteria, error) {
body = true
case 'a':
text = true
+ case 'd':
+ start, end, err := lib.ParseDateRange(opt.Value)
+ if err != nil {
+ log.Errorf("failed to parse start date: %v", err)
+ continue
+ }
+ if !start.IsZero() {
+ criteria.SentSince = start
+ }
+ if !end.IsZero() {
+ criteria.SentBefore = end
+ }
}
}
switch {