about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--commands/msg/forward.go2
-rw-r--r--commands/msg/pipe.go2
-rw-r--r--commands/msg/recall.go2
-rw-r--r--commands/msg/reply.go2
-rw-r--r--commands/msgview/open.go2
-rw-r--r--commands/msgview/save.go29
-rw-r--r--lib/messageview.go8
-rw-r--r--lib/msgstore.go3
-rw-r--r--widgets/msgviewer.go3
9 files changed, 24 insertions, 29 deletions
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index 0b81e52..c044fb6 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -138,7 +138,7 @@ 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, msg.BodyStructure, []int{1}, func(reader io.Reader) {
+		store.FetchBodyPart(msg.Uid, []int{1}, func(reader io.Reader) {
 			buf := new(bytes.Buffer)
 			buf.ReadFrom(reader)
 			original.Text = buf.String()
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index 44b0067..c88d61f 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -127,7 +127,7 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
 	} else if pipePart {
 		p := provider.SelectedMessagePart()
 		store := provider.Store()
-		store.FetchBodyPart(p.Msg.Uid, p.Msg.BodyStructure, p.Index, func(reader io.Reader) {
+		store.FetchBodyPart(p.Msg.Uid, p.Index, func(reader io.Reader) {
 			if background {
 				doExec(reader)
 			} else {
diff --git a/commands/msg/recall.go b/commands/msg/recall.go
index c2f887a..ef7e859 100644
--- a/commands/msg/recall.go
+++ b/commands/msg/recall.go
@@ -114,7 +114,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
 		path = []int{1}
 	}
 
-	store.FetchBodyPart(msgInfo.Uid, part, path, func(reader io.Reader) {
+	store.FetchBodyPart(msgInfo.Uid, path, func(reader io.Reader) {
 		header := message.Header{}
 		header.SetText(
 			"Content-Transfer-Encoding", part.Encoding)
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index 74f0097..72c992e 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -165,7 +165,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
 			template = aerc.Config().Templates.QuotedReply
 		}
 
-		store.FetchBodyPart(msg.Uid, msg.BodyStructure, []int{1}, func(reader io.Reader) {
+		store.FetchBodyPart(msg.Uid, []int{1}, func(reader io.Reader) {
 			buf := new(bytes.Buffer)
 			buf.ReadFrom(reader)
 			original.Text = buf.String()
diff --git a/commands/msgview/open.go b/commands/msgview/open.go
index 44584f9..f708b2d 100644
--- a/commands/msgview/open.go
+++ b/commands/msgview/open.go
@@ -36,7 +36,7 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
 	p := mv.SelectedMessagePart()
 
 	store := mv.Store()
-	store.FetchBodyPart(p.Msg.Uid, p.Msg.BodyStructure, p.Index, func(reader io.Reader) {
+	store.FetchBodyPart(p.Msg.Uid, p.Index, func(reader io.Reader) {
 		extension := ""
 		// try to determine the correct extension based on mimetype
 		if part, err := p.Msg.BodyStructure.PartAtIndex(p.Index); err == nil {
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index f3cbb70..ef6bba8 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -109,21 +109,20 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
 
 	ch := make(chan error, 1)
 	store := mv.Store()
-	store.FetchBodyPart(
-		pi.Msg.Uid, pi.Msg.BodyStructure, pi.Index, func(reader io.Reader) {
-			f, err := os.Create(path)
-			if err != nil {
-				ch <- err
-				return
-			}
-			defer f.Close()
-			_, err = io.Copy(f, reader)
-			if err != nil {
-				ch <- err
-				return
-			}
-			ch <- nil
-		})
+	store.FetchBodyPart(pi.Msg.Uid, pi.Index, func(reader io.Reader) {
+		f, err := os.Create(path)
+		if err != nil {
+			ch <- err
+			return
+		}
+		defer f.Close()
+		_, err = io.Copy(f, reader)
+		if err != nil {
+			ch <- err
+			return
+		}
+		ch <- nil
+	})
 
 	// we need to wait for the callback prior to displaying a result
 	go func() {
diff --git a/lib/messageview.go b/lib/messageview.go
index 3970804..59a1af6 100644
--- a/lib/messageview.go
+++ b/lib/messageview.go
@@ -28,8 +28,7 @@ type MessageView interface {
 	Store() *MessageStore
 
 	// Fetches a specific body part for this message
-	FetchBodyPart(parent *models.BodyStructure,
-		part []int, cb func(io.Reader))
+	FetchBodyPart(part []int, cb func(io.Reader))
 
 	PGPDetails() *openpgp.MessageDetails
 }
@@ -110,11 +109,10 @@ func (msv *MessageStoreView) PGPDetails() *openpgp.MessageDetails {
 	return msv.details
 }
 
-func (msv *MessageStoreView) FetchBodyPart(parent *models.BodyStructure,
-	part []int, cb func(io.Reader)) {
+func (msv *MessageStoreView) FetchBodyPart(part []int, cb func(io.Reader)) {
 
 	if msv.message == nil {
-		msv.messageStore.FetchBodyPart(msv.messageInfo.Uid, parent, part, cb)
+		msv.messageStore.FetchBodyPart(msv.messageInfo.Uid, part, cb)
 		return
 	}
 
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 3fe26cb..7dc2689 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -136,8 +136,7 @@ func (store *MessageStore) FetchFull(uids []uint32, cb func(*types.FullMessage))
 	}
 }
 
-func (store *MessageStore) FetchBodyPart(
-	uid uint32, parent *models.BodyStructure, part []int, cb func(io.Reader)) {
+func (store *MessageStore) FetchBodyPart(uid uint32, part []int, cb func(io.Reader)) {
 
 	store.worker.PostAction(&types.FetchMessageBodyPart{
 		Uid:  uid,
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 0cfabd7..ce85970 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -653,8 +653,7 @@ func (pv *PartViewer) Draw(ctx *ui.Context) {
 		return
 	}
 	if !pv.fetched {
-		pv.msg.FetchBodyPart(pv.msg.BodyStructure(),
-			pv.index, pv.SetSource)
+		pv.msg.FetchBodyPart(pv.index, pv.SetSource)
 		pv.fetched = true
 	}
 	if pv.err != nil {