Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3003,7 +3003,16 @@ pub(crate) async fn create_send_msg_jobs(context: &Context, msg: &mut Message) -
}

let needs_encryption = msg.param.get_bool(Param::GuaranteeE2ee).unwrap_or_default();
let mimefactory = MimeFactory::from_msg(context, msg.clone()).await?;
let mimefactory = match MimeFactory::from_msg(context, msg.clone()).await {
Ok(mf) => mf,
Err(err) => {
// Mark message as failed
message::set_msg_failed(context, msg, &err.to_string())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but if the app crashes before this call or for some other reason doesn't reach even the MimeFactory::from_msg() call, the message will remain OutPending. We need some additional recovery code path pushing such messages through create_send_msg_jobs() again, maybe somewhere in the SMTP loop.

Copy link
Collaborator

@Hocuri Hocuri Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR already works in 99.9% of cases, which is good enough here - it's super unlikely that a) an outgoing message fails AND b) the app will by chance be killed at this exact moment. And if some outgoing message makes core crash (i.e. panic-abort), it's actually better not to process it again.

.await
.ok();
return Err(err);
}
};
let attach_selfavatar = mimefactory.attach_selfavatar;
let mut recipients = mimefactory.recipients();

Expand Down
Loading