mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 14:56:33 +03:00
smtp: set message state to failed when retry limit is exceeded
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
- Fix a bug where messages in the Spam folder created contact requests #3015
|
- Fix a bug where messages in the Spam folder created contact requests #3015
|
||||||
- Fix a bug where drafts disappeared after some days #3067
|
- Fix a bug where drafts disappeared after some days #3067
|
||||||
- do not retry message sending infinitely in case of permanent SMTP failure #3070
|
- do not retry message sending infinitely in case of permanent SMTP failure #3070
|
||||||
|
- set message state to failed when retry limit is exceeded #3072
|
||||||
|
|
||||||
|
|
||||||
## 1.75.0
|
## 1.75.0
|
||||||
|
|||||||
26
src/smtp.rs
26
src/smtp.rs
@@ -356,19 +356,35 @@ 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) = context
|
let (body, recipients, msg_id, retries) = context
|
||||||
.sql
|
.sql
|
||||||
.query_row(
|
.query_row(
|
||||||
"SELECT mime, recipients, msg_id FROM smtp WHERE id=?",
|
"SELECT mime, recipients, msg_id, retries FROM smtp WHERE id=?",
|
||||||
paramsv![rowid],
|
paramsv![rowid],
|
||||||
|row| {
|
|row| {
|
||||||
let mime: String = row.get(0)?;
|
let mime: String = row.get(0)?;
|
||||||
let recipients: String = row.get(1)?;
|
let recipients: String = row.get(1)?;
|
||||||
let msg_id: MsgId = row.get(2)?;
|
let msg_id: MsgId = row.get(2)?;
|
||||||
Ok((mime, recipients, msg_id))
|
let retries: i64 = row.get(3)?;
|
||||||
|
Ok((mime, recipients, msg_id, retries))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
if retries > 6 {
|
||||||
|
message::set_msg_failed(
|
||||||
|
context,
|
||||||
|
msg_id,
|
||||||
|
Some("Number of retries exceeded the limit."),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
context
|
||||||
|
.sql
|
||||||
|
.execute("DELETE FROM smtp WHERE id=?", paramsv![rowid])
|
||||||
|
.await
|
||||||
|
.context("failed to remove message with exceeded retry limit from smtp table")?;
|
||||||
|
bail!("Number of retries exceeded the limit");
|
||||||
|
}
|
||||||
|
|
||||||
let recipients_list = recipients
|
let recipients_list = recipients
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.filter_map(
|
.filter_map(
|
||||||
@@ -456,10 +472,6 @@ pub(crate) async fn send_smtp_messages(
|
|||||||
connection: &mut Smtp,
|
connection: &mut Smtp,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
context.send_sync_msg().await?; // Add sync message to the end of the queue if needed.
|
context.send_sync_msg().await?; // Add sync message to the end of the queue if needed.
|
||||||
context
|
|
||||||
.sql
|
|
||||||
.execute("DELETE FROM smtp WHERE retries > 5", paramsv![])
|
|
||||||
.await?;
|
|
||||||
let rowids = context
|
let rowids = context
|
||||||
.sql
|
.sql
|
||||||
.query_map(
|
.query_map(
|
||||||
|
|||||||
Reference in New Issue
Block a user