From 1b912fbbe98ae9b0a78da2b448f6121944d9b9b1 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sat, 13 Apr 2024 21:15:56 +0200 Subject: compose: explicitly identify converted text/* parts When running :accept, an error is displayed on the review screen: text/calendar error: no command defined for mime/type When running :multipart text/xxx, its contents are not specified. They are regenerated every time the review screen is displayed. When running :accept, a text/calendar part is added with actual contents. Update the Part object to hold a boolean initialized when first being created. If body is nil, identify the part as "Converted" and update its contents every time the review screen is displayed. When body is not nil but contains text (e.g. when running :accept), identify the part as *not* converted and ignore the conversion step. Fixes: cbcabfafaab2 ("compose: allow writing multipart/alternative messages") Reported-by: Inwit Signed-off-by: Robin Jarry Tested-by: Inwit --- lib/attachment.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/attachment.go b/lib/attachment.go index 6f29da55..a5f1b034 100644 --- a/lib/attachment.go +++ b/lib/attachment.go @@ -19,19 +19,28 @@ type Part struct { MimeType string Params map[string]string Data []byte + Converted bool ConversionError error } func NewPart(mimetype string, params map[string]string, body io.Reader, ) (*Part, error) { - d, err := io.ReadAll(body) - if err != nil { - return nil, err + var d []byte + var err error + var converted bool + if body == nil { + converted = true + } else { + d, err = io.ReadAll(body) + if err != nil { + return nil, err + } } return &Part{ - MimeType: mimetype, - Params: params, - Data: d, + MimeType: mimetype, + Params: params, + Data: d, + Converted: converted, }, nil } -- cgit