aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir
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/maildir
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/maildir')
-rw-r--r--worker/maildir/message.go9
-rw-r--r--worker/maildir/search.go4
2 files changed, 7 insertions, 6 deletions
diff --git a/worker/maildir/message.go b/worker/maildir/message.go
index 778673a2..1f89cfe3 100644
--- a/worker/maildir/message.go
+++ b/worker/maildir/message.go
@@ -6,6 +6,7 @@ import (
"github.com/emersion/go-maildir"
+ "git.sr.ht/~rjarry/aerc/lib/rfc822"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/lib"
@@ -74,7 +75,7 @@ func (m Message) Remove() error {
// MessageInfo populates a models.MessageInfo struct for the message.
func (m Message) MessageInfo() (*models.MessageInfo, error) {
- info, err := lib.MessageInfo(m)
+ info, err := rfc822.MessageInfo(m)
if err != nil {
return nil, err
}
@@ -101,7 +102,7 @@ func (m Message) Size() (uint32, error) {
// MessageHeaders populates a models.MessageInfo struct for the message with
// minimal information, used for sorting and threading.
func (m Message) MessageHeaders() (*models.MessageInfo, error) {
- info, err := lib.MessageHeaders(m)
+ info, err := rfc822.MessageHeaders(m)
if err != nil {
return nil, err
}
@@ -121,11 +122,11 @@ func (m Message) NewBodyPartReader(requestedParts []int) (io.Reader, error) {
return nil, err
}
defer f.Close()
- msg, err := lib.ReadMessage(f)
+ msg, err := rfc822.ReadMessage(f)
if err != nil {
return nil, fmt.Errorf("could not read message: %w", err)
}
- return lib.FetchEntityPartReader(msg, requestedParts)
+ return rfc822.FetchEntityPartReader(msg, requestedParts)
}
func (m Message) UID() uint32 {
diff --git a/worker/maildir/search.go b/worker/maildir/search.go
index 8286de67..c1ea4de2 100644
--- a/worker/maildir/search.go
+++ b/worker/maildir/search.go
@@ -15,9 +15,9 @@ import (
"git.sr.ht/~sircmpwn/getopt"
"git.sr.ht/~rjarry/aerc/lib"
+ "git.sr.ht/~rjarry/aerc/lib/parse"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
- wlib "git.sr.ht/~rjarry/aerc/worker/lib"
)
type searchCriteria struct {
@@ -69,7 +69,7 @@ func parseSearch(args []string) (*searchCriteria, error) {
case 'a':
text = true
case 'd':
- start, end, err := wlib.ParseDateRange(opt.Value)
+ start, end, err := parse.DateRange(opt.Value)
if err != nil {
log.Errorf("failed to parse start date: %v", err)
continue