summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-01-04 21:13:51 +0100
committerDrew DeVault <sir@cmpwn.com>2020-01-05 16:02:45 -0500
commit9096049f757ca0a43ac5cbad7eb27db8c1897d91 (patch)
treea60080179514c9862b75a16deaf6dc7c82e65baf /lib
parent19dfc49481c6c8271115658c46ea68a1c977f1d0 (diff)
downloadaerc-9096049f757ca0a43ac5cbad7eb27db8c1897d91.tar.gz
FetchBodyParts: decode source in the workers
Previously the workers returned a mixture of decoded / encoded parts.
This lead to a whole bunch of issues.
This commit changes the msgviewer and the commands to assume parts to already
be decoded
Diffstat (limited to 'lib')
-rw-r--r--lib/msgstore.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index f67c49f..7209316 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -127,11 +127,22 @@ func (store *MessageStore) FetchFull(uids []uint32, cb func(io.Reader)) {
 }
 
 func (store *MessageStore) FetchBodyPart(
-	uid uint32, part []int, cb func(io.Reader)) {
+	uid uint32, parent *models.BodyStructure, part []int, cb func(io.Reader)) {
+	partbs, err := parent.PartAtIndex(part)
+	if err != nil {
+		store.worker.Logger.Printf("FetchBodyPart: %v\n", err)
+	}
+	var charset string
+	var ok bool
+	if charset, ok = partbs.Params["charset"]; !ok {
+		charset = ""
+	}
 
 	store.worker.PostAction(&types.FetchMessageBodyPart{
-		Uid:  uid,
-		Part: part,
+		Uid:      uid,
+		Part:     part,
+		Encoding: partbs.Encoding,
+		Charset:  charset,
 	}, func(resp types.WorkerMessage) {
 		msg, ok := resp.(*types.MessageBodyPart)
 		if !ok {