about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-05-17 13:02:24 +0200
committerReto Brunner <reto@labrat.space>2020-05-17 13:02:24 +0200
commit61e994084975e86c53dec89cca49f99693e77424 (patch)
treee4a9facf1bb87f138bbe856771e28c5a6d9aa099
parentd48ea6231c76fbfff334be647c8c4d05bf9de387 (diff)
downloadaerc-61e994084975e86c53dec89cca49f99693e77424.tar.gz
msg/forward: fix body part selection
-rw-r--r--commands/msg/forward.go10
1 files 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()
' href='#n129'>129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190