aboutsummaryrefslogtreecommitdiffstats
path: root/worker/lib/search.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-10-17 14:40:08 +0200
committerRobin Jarry <robin@jarry.cc>2023-10-28 19:24:55 +0200
commit57088312fdd8e602a084bd5736a0e22a34be9ec0 (patch)
tree8c5544262cf8c1772ec661748cfa4d5491ff4c77 /worker/lib/search.go
parent591659b52867cb118d1f82d41693a02123935e0c (diff)
downloadaerc-57088312fdd8e602a084bd5736a0e22a34be9ec0.tar.gz
worker: move shared code to lib
Avoid importing code from worker/lib into lib. It should only be the other way around. Move the message parsing code used by maildir, notmuch, mbox and the eml viewer into a lib/rfc822 package. Adapt imports accordingly. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'worker/lib/search.go')
-rw-r--r--worker/lib/search.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/worker/lib/search.go b/worker/lib/search.go
index 11fc1b11..cd372aae 100644
--- a/worker/lib/search.go
+++ b/worker/lib/search.go
@@ -9,6 +9,8 @@ import (
"git.sr.ht/~sircmpwn/getopt"
+ "git.sr.ht/~rjarry/aerc/lib/parse"
+ "git.sr.ht/~rjarry/aerc/lib/rfc822"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
)
@@ -60,7 +62,7 @@ func GetSearchCriteria(args []string) (*searchCriteria, error) {
case 'b':
body = true
case 'd':
- start, end, err := ParseDateRange(opt.Value)
+ start, end, err := parse.DateRange(opt.Value)
if err != nil {
log.Errorf("failed to parse start date: %v", err)
continue
@@ -99,7 +101,7 @@ func getParsedFlag(name string) models.Flags {
return f
}
-func Search(messages []RawMessage, criteria *searchCriteria) ([]uint32, error) {
+func Search(messages []rfc822.RawMessage, criteria *searchCriteria) ([]uint32, error) {
requiredParts := getRequiredParts(criteria)
matchedUids := []uint32{}
@@ -117,7 +119,7 @@ func Search(messages []RawMessage, criteria *searchCriteria) ([]uint32, error) {
// searchMessage executes the search criteria for the given RawMessage,
// returns true if search succeeded
-func searchMessage(message RawMessage, criteria *searchCriteria,
+func searchMessage(message rfc822.RawMessage, criteria *searchCriteria,
parts MsgParts,
) (bool, error) {
// setup parts of the message to use in the search
@@ -137,7 +139,7 @@ func searchMessage(message RawMessage, criteria *searchCriteria,
}
}
if parts&HEADER > 0 || parts&DATE > 0 {
- header, err = MessageInfo(message)
+ header, err = rfc822.MessageInfo(message)
if err != nil {
return false, err
}