summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-31 12:14:37 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-31 12:14:37 -0400
commit27b25174e2f0249a6a1d4ba45b70f8504b63ffb1 (patch)
treeb8626c746e07d9a38f95a5a817a7094c9275bfd1 /lib
parent143289bbd0736d72553a3c2a080aa3d125366b38 (diff)
downloadaerc-27b25174e2f0249a6a1d4ba45b70f8504b63ffb1.tar.gz
Make the message viewer real, part one
Diffstat (limited to 'lib')
-rw-r--r--lib/msgstore.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 64b1638..2169b2e 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -67,7 +67,6 @@ func (store *MessageStore) FetchHeaders(uids []uint32,
 }
 
 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.
 	var toFetch imap.SeqSet
@@ -89,6 +88,21 @@ func (store *MessageStore) FetchBodies(uids []uint32, cb func(io.Reader)) {
 	}
 }
 
+func (store *MessageStore) FetchBodyPart(
+	uid uint32, part int, cb func(io.Reader)) {
+
+	store.worker.PostAction(&types.FetchMessageBodyPart{
+		Uid:  uid,
+		Part: part,
+	}, func(resp types.WorkerMessage) {
+		msg, ok := resp.(*types.MessageBodyPart)
+		if !ok {
+			return
+		}
+		cb(msg.Reader)
+	})
+}
+
 func (store *MessageStore) merge(
 	to *types.MessageInfo, from *types.MessageInfo) {