mirror of
https://github.com/chatmail/core.git
synced 2026-05-25 09:46:31 +03:00
Mark all failed messages as failed when receiving an NDN
There may be multiple messages with the same `Message-Id`-header alias rfc724_mid because an email with multiple attachments was split up.
This commit is contained in:
@@ -1643,9 +1643,9 @@ pub(crate) async fn handle_ndn(
|
||||
return;
|
||||
}
|
||||
|
||||
let res = context
|
||||
let res: Result<Vec<_>, _> = context
|
||||
.sql
|
||||
.query_row(
|
||||
.query_map(
|
||||
concat!(
|
||||
"SELECT",
|
||||
" m.id AS msg_id,",
|
||||
@@ -1662,15 +1662,33 @@ pub(crate) async fn handle_ndn(
|
||||
row.get::<_, Chattype>("type")?,
|
||||
))
|
||||
},
|
||||
|rows| Ok(rows.collect::<Vec<_>>()),
|
||||
)
|
||||
.await;
|
||||
|
||||
if let Err(ref err) = res {
|
||||
info!(context, "Failed to select NDN {:?}", err);
|
||||
}
|
||||
|
||||
if let Ok((msg_id, chat_id, chat_type)) = res {
|
||||
set_msg_failed(context, msg_id, error).await;
|
||||
if let Ok(msgs) = res {
|
||||
for msg in msgs.iter() {
|
||||
match msg {
|
||||
Ok((msg_id, chat_id, chat_type)) => {
|
||||
set_msg_failed(context, *msg_id, error.as_ref()).await;
|
||||
ndn_maybe_add_info_msg(context, failed, *chat_id, *chat_type).await;
|
||||
}
|
||||
Err(e) => warn!(context, "ndn error: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn ndn_maybe_add_info_msg(
|
||||
context: &Context,
|
||||
failed: &FailureReport,
|
||||
chat_id: ChatId,
|
||||
chat_type: Chattype,
|
||||
) {
|
||||
if chat_type == Chattype::Group {
|
||||
if let Some(failed_recipient) = &failed.failed_recipient {
|
||||
let contact_id =
|
||||
@@ -1692,7 +1710,6 @@ pub(crate) async fn handle_ndn(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The number of messages assigned to real chat (!=deaddrop, !=trash)
|
||||
|
||||
Reference in New Issue
Block a user