Skip to content

Commit ded8c02

Browse files
committed
fix(send_msg_to_smtp): do not fail if the message does not exist anymore
If the number of retries for message is exceeded, do not fail when marking it as failed if the message does not exist. Otherwise we may never delete the message from SMTP queue because corresponding msg_id is not valid anymore.
1 parent cbca510 commit ded8c02

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/smtp.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,10 @@ pub(crate) async fn send_msg_to_smtp(
372372
)
373373
.await?;
374374
if retries > 6 {
375-
let mut msg = Message::load_from_db(context, msg_id).await?;
376-
message::set_msg_failed(context, &mut msg, "Number of retries exceeded the limit.").await?;
375+
if let Some(mut msg) = Message::load_from_db_optional(context, msg_id).await? {
376+
message::set_msg_failed(context, &mut msg, "Number of retries exceeded the limit.")
377+
.await?;
378+
}
377379
context
378380
.sql
379381
.execute("DELETE FROM smtp WHERE id=?", (rowid,))

0 commit comments

Comments
 (0)