Skip to content

Commit

Permalink
fix(send_msg_to_smtp): do not fail if the message does not exist anymore
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
link2xt committed Nov 1, 2024
1 parent cbca510 commit ded8c02
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/smtp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,10 @@ pub(crate) async fn send_msg_to_smtp(
)
.await?;
if retries > 6 {
let mut msg = Message::load_from_db(context, msg_id).await?;
message::set_msg_failed(context, &mut msg, "Number of retries exceeded the limit.").await?;
if let Some(mut msg) = Message::load_from_db_optional(context, msg_id).await? {
message::set_msg_failed(context, &mut msg, "Number of retries exceeded the limit.")
.await?;
}
context
.sql
.execute("DELETE FROM smtp WHERE id=?", (rowid,))
Expand Down

0 comments on commit ded8c02

Please sign in to comment.