summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-31 11:29:57 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-31 11:29:57 -0400
commit143289bbd0736d72553a3c2a080aa3d125366b38 (patch)
tree6a2e97db785db1385063323708764cb93388a4d0 /lib
parent1f23868652a2ce0e81bddd048e3e828efaff2d69 (diff)
downloadaerc-143289bbd0736d72553a3c2a080aa3d125366b38.tar.gz
Don't parse mail in worker; send a reader instead
Diffstat (limited to 'lib')
-rw-r--r--lib/msgstore.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index c6cd2c3..64b1638 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -1,10 +1,10 @@
 package lib
 
 import (
+	"io"
 	"time"
 
 	"github.com/emersion/go-imap"
-	"github.com/mohamedattahri/mail"
 
 	"git.sr.ht/~sircmpwn/aerc2/worker/types"
 )
@@ -16,7 +16,7 @@ type MessageStore struct {
 	// Ordered list of known UIDs
 	Uids []uint32
 
-	bodyCallbacks   map[uint32][]func(*mail.Message)
+	bodyCallbacks   map[uint32][]func(io.Reader)
 	headerCallbacks map[uint32][]func(*types.MessageInfo)
 
 	// Map of uids we've asked the worker to fetch
@@ -33,7 +33,7 @@ func NewMessageStore(worker *types.Worker,
 		Deleted: make(map[uint32]interface{}),
 		DirInfo: *dirInfo,
 
-		bodyCallbacks:   make(map[uint32][]func(*mail.Message)),
+		bodyCallbacks:   make(map[uint32][]func(io.Reader)),
 		headerCallbacks: make(map[uint32][]func(*types.MessageInfo)),
 
 		pendingBodies:  make(map[uint32]interface{}),
@@ -66,8 +66,7 @@ func (store *MessageStore) FetchHeaders(uids []uint32,
 	}
 }
 
-func (store *MessageStore) FetchBodies(uids []uint32,
-	cb func(*mail.Message)) {
+func (store *MessageStore) FetchBodies(uids []uint32, cb func(io.Reader)) {
 
 	// TODO: this could be optimized by pre-allocating toFetch and trimming it
 	// at the end. In practice we expect to get most messages back in one frame.
@@ -80,7 +79,7 @@ func (store *MessageStore) FetchBodies(uids []uint32,
 				if list, ok := store.bodyCallbacks[uid]; ok {
 					store.bodyCallbacks[uid] = append(list, cb)
 				} else {
-					store.bodyCallbacks[uid] = []func(*mail.Message){cb}
+					store.bodyCallbacks[uid] = []func(io.Reader){cb}
 				}
 			}
 		}
@@ -149,7 +148,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
 			delete(store.pendingBodies, msg.Uid)
 			if cbs, ok := store.bodyCallbacks[msg.Uid]; ok {
 				for _, cb := range cbs {
-					cb(msg.Mail)
+					cb(msg.Reader)
 				}
 			}
 		}