fix: Split SMTP jobs already in chat::create_send_msg_jobs() (#5115)

a27e84ad89 "fix: Delete received outgoing messages from SMTP queue"
can break sending messages sent as several SMTP messages because they have a lot of recipients:
`pub(crate) const DEFAULT_MAX_SMTP_RCPT_TO: usize = 50;`

We should not cancel sending if it is such a message and we received BCC-self because it does not
mean the other part was sent successfully. For this, split such messages into separate jobs in the
`smtp` table so that only a job containing BCC-self is canceled from `receive_imf_inner()`. Although
this doesn't solve the initial problem with timed-out SMTP requests for such messages completely,
this enables fine-grained SMTP retries so we don't need to resend all SMTP messages if only some of
them failed to be sent.
This commit is contained in:
iequidoo
2023-12-29 21:14:42 -03:00
committed by iequidoo
parent b7c34b7794
commit 625887d249
7 changed files with 177 additions and 93 deletions

View File

@@ -1665,7 +1665,10 @@ pub(crate) async fn update_msg_state(
) -> Result<()> {
context
.sql
.execute("UPDATE msgs SET state=? WHERE id=?;", (state, msg_id))
.execute(
"UPDATE msgs SET state=?1 WHERE id=?2 AND (?1!=?3 OR state<?3)",
(state, msg_id, MessageState::OutDelivered),
)
.await?;
Ok(())
}