mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 22:36:30 +03:00
fix: send_msg_to_smtp: Return Ok if smtp row is deleted in parallel
Follow-up to ded8c02c0f. `smtp` rows may be deleted in parallel, in
this case there's just nothing to send.
This commit is contained in:
@@ -4505,6 +4505,7 @@ pub(crate) async fn delete_and_reset_all_device_msgs(context: &Context) -> Resul
|
|||||||
/// Adds an informational message to chat.
|
/// Adds an informational message to chat.
|
||||||
///
|
///
|
||||||
/// For example, it can be a message showing that a member was added to a group.
|
/// For example, it can be a message showing that a member was added to a group.
|
||||||
|
/// Doesn't fail if the chat doesn't exist.
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub(crate) async fn add_info_msg_with_cmd(
|
pub(crate) async fn add_info_msg_with_cmd(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
|
|||||||
@@ -357,9 +357,9 @@ pub(crate) async fn send_msg_to_smtp(
|
|||||||
.await
|
.await
|
||||||
.context("failed to update retries count")?;
|
.context("failed to update retries count")?;
|
||||||
|
|
||||||
let (body, recipients, msg_id, retries) = context
|
let Some((body, recipients, msg_id, retries)) = context
|
||||||
.sql
|
.sql
|
||||||
.query_row(
|
.query_row_optional(
|
||||||
"SELECT mime, recipients, msg_id, retries FROM smtp WHERE id=?",
|
"SELECT mime, recipients, msg_id, retries FROM smtp WHERE id=?",
|
||||||
(rowid,),
|
(rowid,),
|
||||||
|row| {
|
|row| {
|
||||||
@@ -370,7 +370,10 @@ pub(crate) async fn send_msg_to_smtp(
|
|||||||
Ok((mime, recipients, msg_id, retries))
|
Ok((mime, recipients, msg_id, retries))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?
|
||||||
|
else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
if retries > 6 {
|
if retries > 6 {
|
||||||
if let Some(mut msg) = Message::load_from_db_optional(context, msg_id).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.")
|
message::set_msg_failed(context, &mut msg, "Number of retries exceeded the limit.")
|
||||||
|
|||||||
Reference in New Issue
Block a user