webmail: fix loading a "view" (messages in a mailbox) when the "initial" message cannot be parsed

when we send a list of messages from the mox backend to the js frontend, we
include a parsed form of the "initial" message: the one we immediately show,
typically the top-most (unread) message. however, if that message could not be
parsed (due to invalid header syntax), we would fail the entire operation of
loading the view.

with this change, we simply don't return a parsed form of an initial message if
we cannot parse it. that will cause the webmail frontend to not select &
display a message immediately. if you then try to open the message, you'll
still get an error message as before. but at least the view has been loaded,
and you can open the raw message to inspect the contents.

for issue #219 by wneessen
This commit is contained in:
Mechiel Lukkien
2024-10-05 09:39:46 +02:00
parent 5d97bf198a
commit fb65ec0676
3 changed files with 26 additions and 8 deletions

View File

@ -232,7 +232,7 @@ func parsedMessage(log mlog.Log, m store.Message, state *msgState, full, msgitem
if full && state.part.BodyOffset > 0 {
hdrs, err := state.part.Header()
if err != nil {
return ParsedMessage{}, fmt.Errorf("parsing headers: %v", err)
return ParsedMessage{}, fmt.Errorf("parsing headers: %w", err)
}
pm.Headers = hdrs