aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/msg/forward.go26
-rw-r--r--commands/msg/pipe.go12
-rw-r--r--commands/msg/reply.go55
-rw-r--r--commands/msgview/open.go2
-rw-r--r--commands/msgview/save.go2
5 files changed, 8 insertions, 89 deletions
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index 7570177..35d276e 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -10,9 +10,6 @@ import (
"path"
"strings"
- "github.com/emersion/go-message"
- "github.com/emersion/go-message/mail"
-
"git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/widgets"
"git.sr.ht/~sircmpwn/getopt"
@@ -138,28 +135,9 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
// TODO: something more intelligent than fetching the 1st part
// TODO: add attachments!
- store.FetchBodyPart(msg.Uid, []int{1}, func(reader io.Reader) {
- header := message.Header{}
- header.SetText(
- "Content-Transfer-Encoding", msg.BodyStructure.Encoding)
- header.SetContentType(
- msg.BodyStructure.MIMEType, 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()
})
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index 2faa5de..001577c 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -1,13 +1,10 @@
package msg
import (
- "encoding/base64"
"errors"
"fmt"
"io"
- "mime/quotedprintable"
"os/exec"
- "strings"
"time"
"git.sr.ht/~sircmpwn/aerc/commands"
@@ -129,14 +126,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
})
} else if pipePart {
p := provider.SelectedMessagePart()
- p.Store.FetchBodyPart(p.Msg.Uid, p.Index, func(reader io.Reader) {
- // email parts are encoded as 7bit (plaintext), quoted-printable, or base64
- if strings.EqualFold(p.Part.Encoding, "base64") {
- reader = base64.NewDecoder(base64.StdEncoding, reader)
- } else if strings.EqualFold(p.Part.Encoding, "quoted-printable") {
- reader = quotedprintable.NewReader(reader)
- }
-
+ p.Store.FetchBodyPart(p.Msg.Uid, p.Msg.BodyStructure, p.Index, func(reader io.Reader) {
if background {
doExec(reader)
} else {
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 359c5dd..a7379d7 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) {
diff --git a/commands/msgview/open.go b/commands/msgview/open.go
index ab023a1..6001d28 100644
--- a/commands/msgview/open.go
+++ b/commands/msgview/open.go
@@ -36,7 +36,7 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
mv := aerc.SelectedTab().(*widgets.MessageViewer)
p := mv.SelectedMessagePart()
- p.Store.FetchBodyPart(p.Msg.Uid, p.Index, func(reader io.Reader) {
+ p.Store.FetchBodyPart(p.Msg.Uid, p.Msg.BodyStructure, p.Index, func(reader io.Reader) {
// email parts are encoded as 7bit (plaintext), quoted-printable, or base64
if strings.EqualFold(p.Part.Encoding, "base64") {
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 99abe0e..c017e70 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -60,7 +60,7 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
mv := aerc.SelectedTab().(*widgets.MessageViewer)
p := mv.SelectedMessagePart()
- p.Store.FetchBodyPart(p.Msg.Uid, p.Index, func(reader io.Reader) {
+ p.Store.FetchBodyPart(p.Msg.Uid, p.Msg.BodyStructure, p.Index, func(reader io.Reader) {
// email parts are encoded as 7bit (plaintext), quoted-printable, or base64
if strings.EqualFold(p.Part.Encoding, "base64") {