about summary refs log tree commit diff stats
path: root/commands/msg/recall.go
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-06-19 17:58:08 +0200
committerReto Brunner <reto@labrat.space>2020-07-27 09:19:27 +0200
commitc574a838fa89bf46bf7188442f400b206b04df95 (patch)
tree89c40ba4a7f5f5a2e67ca8fb225f7d5d3eb319ad /commands/msg/recall.go
parent494bd674a98bc9f2889acad0fda3ff4c77c641b5 (diff)
downloadaerc-c574a838fa89bf46bf7188442f400b206b04df95.tar.gz
Remove hard coded bodystruct path everywhere
Aerc usually used the path []int{1} if it didn't know what the proper path is.
However this only works for multipart messages and breaks if it isn't one.

This patch removes all the hard coding and extracts the necessary helpers to lib.
Diffstat (limited to 'commands/msg/recall.go')
-rw-r--r--commands/msg/recall.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/commands/msg/recall.go b/commands/msg/recall.go
index 7c9ac19..5212041 100644
--- a/commands/msg/recall.go
+++ b/commands/msg/recall.go
@@ -8,6 +8,7 @@ import (
 	"github.com/emersion/go-message/mail"
 	"github.com/pkg/errors"
 
+	"git.sr.ht/~sircmpwn/aerc/lib"
 	"git.sr.ht/~sircmpwn/aerc/models"
 	"git.sr.ht/~sircmpwn/aerc/widgets"
 	"git.sr.ht/~sircmpwn/aerc/worker/types"
@@ -107,12 +108,11 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
 		part *models.BodyStructure
 	)
 	if len(msgInfo.BodyStructure.Parts) != 0 {
-		path = findPlaintext(msgInfo.BodyStructure, path)
+		path = lib.FindPlaintext(msgInfo.BodyStructure, path)
 	}
 	part, err = msgInfo.BodyStructure.PartAtIndex(path)
 	if part == nil || err != nil {
 		part = msgInfo.BodyStructure
-		path = []int{1}
 	}
 
 	store.FetchBodyPart(msgInfo.Uid, path, func(reader io.Reader) {