From c574a838fa89bf46bf7188442f400b206b04df95 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Fri, 19 Jun 2020 17:58:08 +0200 Subject: 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. --- commands/msg/reply.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'commands/msg/reply.go') diff --git a/commands/msg/reply.go b/commands/msg/reply.go index 1deab316..6fd61413 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -10,6 +10,7 @@ import ( "git.sr.ht/~sircmpwn/getopt" + "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/models" "git.sr.ht/~sircmpwn/aerc/widgets" ) @@ -169,14 +170,12 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { template = aerc.Config().Templates.QuotedReply } - part := findPlaintext(msg.BodyStructure, nil) + part := lib.FindPlaintext(msg.BodyStructure, nil) if part == nil { - //mkey... let's get the first thing that isn't a container - part = findFirstNonMultipart(msg.BodyStructure, nil) - if part == nil { - // give up, use whatever is first - part = []int{1} - } + // mkey... let's get the first thing that isn't a container + // if that's still nil it's either not a multipart msg (ok) or + // broken (containers only) + part = lib.FindFirstNonMultipart(msg.BodyStructure, nil) } store.FetchBodyPart(msg.Uid, part, func(reader io.Reader) { buf := new(bytes.Buffer) -- cgit