From a320fb9d6cba7b70adab669bd06a5fa36920972e Mon Sep 17 00:00:00 2001 From: Hocuri Date: Mon, 19 Oct 2020 13:29:10 +0200 Subject: [PATCH] Doesn't look great, but this was the only way to make compiler happy --- src/message.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/message.rs b/src/message.rs index 72390d867..023368109 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1640,11 +1640,12 @@ pub(crate) async fn handle_ndn( error: Option>, ) -> anyhow::Result<()> { if failed.rfc724_mid.is_empty() { - return; + return Ok(()); } -/// The NDN might be for a message-id that had attachments and was sent from a non-Delta Chat client. -/// In this case we need to mark multiple "msgids" as failed that all refer to the same message-id. - let msgs: Result, _> = context + + // The NDN might be for a message-id that had attachments and was sent from a non-Delta Chat client. + // In this case we need to mark multiple "msgids" as failed that all refer to the same message-id. + let msgs: Vec<_> = context .sql .query_map( concat!( @@ -1667,15 +1668,13 @@ pub(crate) async fn handle_ndn( ) .await?; - for msg in msgs.iter() { + for (i, msg) in msgs.into_iter().enumerate() { let (msg_id, chat_id, chat_type) = msg?; - set_msg_failed(context, *msg_id, error.as_ref()).await?; - } - - if let Some(msg) = msgs.last() { - let (msg_id, chat_id, chat_type) = msg?; - // Add only one info msg for all failed messages - ndn_maybe_add_info_msg(context, failed, chat_id, chat_type).await?; + set_msg_failed(context, msg_id, error.as_ref()).await; + if i == 0 { + // Add only one info msg for all failed messages + ndn_maybe_add_info_msg(context, failed, chat_id, chat_type).await?; + } } Ok(())