From 61e994084975e86c53dec89cca49f99693e77424 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Sun, 17 May 2020 13:02:24 +0200 Subject: [PATCH] msg/forward: fix body part selection --- commands/msg/forward.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/commands/msg/forward.go b/commands/msg/forward.go index c044fb6..28abbed 100644 --- a/commands/msg/forward.go +++ b/commands/msg/forward.go @@ -136,9 +136,15 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error { template = aerc.Config().Templates.Forwards } - // TODO: something more intelligent than fetching the 1st part // TODO: add attachments! - store.FetchBodyPart(msg.Uid, []int{1}, func(reader io.Reader) { + part := findPlaintext(msg.BodyStructure, nil) + if part == nil { + part = findFirstNonMultipart(msg.BodyStructure, nil) + if part == nil { + part = []int{1} + } + } + store.FetchBodyPart(msg.Uid, part, func(reader io.Reader) { buf := new(bytes.Buffer) buf.ReadFrom(reader) original.Text = buf.String()