aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg/reply.go
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 /commands/msg/reply.go
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 'commands/msg/reply.go')
-rw-r--r--commands/msg/reply.go55
1 files changed, 3 insertions, 52 deletions
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 359c5dd5..a7379d75 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -9,9 +9,6 @@ import (
"strings"
"git.sr.ht/~sircmpwn/getopt"
- "github.com/emersion/go-message"
- _ "github.com/emersion/go-message/charset"
- "github.com/emersion/go-message/mail"
"git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/widgets"
@@ -155,56 +152,9 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
template = aerc.Config().Templates.QuotedReply
}
- store.FetchBodyPart(msg.Uid, []int{1}, func(reader io.Reader) {
- header := message.Header{}
- if len(msg.BodyStructure.Parts) > 0 {
- partID := 0 // TODO: will we always choose first msg part?
- header.SetText(
- "Content-Transfer-Encoding", msg.BodyStructure.Parts[partID].Encoding)
- if msg.BodyStructure.Parts[partID].MIMESubType == "" {
- header.SetContentType(
- msg.BodyStructure.Parts[partID].MIMEType,
- msg.BodyStructure.Parts[partID].Params)
- } else {
- // include SubType if defined (text/plain, text/html, ...)
- header.SetContentType(
- fmt.Sprintf("%s/%s", msg.BodyStructure.Parts[partID].MIMEType,
- msg.BodyStructure.Parts[partID].MIMESubType),
- msg.BodyStructure.Parts[partID].Params)
- }
- header.SetText("Content-Description", msg.BodyStructure.Parts[partID].Description)
- } else { // Parts has no headers, so we use global headers info
- header.SetText(
- "Content-Transfer-Encoding", msg.BodyStructure.Encoding)
- if msg.BodyStructure.MIMESubType == "" {
- header.SetContentType(
- msg.BodyStructure.MIMEType,
- msg.BodyStructure.Params)
- } else {
- // include SubType if defined (text/plain, text/html, ...)
- header.SetContentType(
- fmt.Sprintf("%s/%s", msg.BodyStructure.MIMEType,
- msg.BodyStructure.MIMESubType),
- msg.BodyStructure.Params)
- }
- header.SetText("Content-Description", msg.BodyStructure.Description)
- }
- entity, err := message.New(header, reader)
- if err != nil {
- // TODO: Do something with the error
- addTab()
- return
- }
- mreader := mail.NewReader(entity)
- part, err := mreader.NextPart()
- if err != nil {
- // TODO: Do something with the error
- addTab()
- return
- }
-
+ store.FetchBodyPart(msg.Uid, msg.BodyStructure, []int{1}, func(reader io.Reader) {
buf := new(bytes.Buffer)
- buf.ReadFrom(part.Body)
+ buf.ReadFrom(reader)
defaults["Original"] = buf.String()
addTab()
})
@@ -214,6 +164,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
}
}
+//TODO (RPB): unused function
func findPlaintext(bs *models.BodyStructure,
path []int) (*models.BodyStructure, []int) {