Doesn't look great, but this was the only way to make compiler happy

This commit is contained in:
Hocuri
2020-10-19 13:29:10 +02:00
committed by holger krekel
parent 3bef4909d5
commit a320fb9d6c

View File

@@ -1640,11 +1640,12 @@ pub(crate) async fn handle_ndn(
error: Option<impl AsRef<str>>, error: Option<impl AsRef<str>>,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
if failed.rfc724_mid.is_empty() { 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. // The NDN might be for a message-id that had attachments and was sent from a non-Delta Chat client.
let msgs: Result<Vec<_>, _> = context // In this case we need to mark multiple "msgids" as failed that all refer to the same message-id.
let msgs: Vec<_> = context
.sql .sql
.query_map( .query_map(
concat!( concat!(
@@ -1667,16 +1668,14 @@ pub(crate) async fn handle_ndn(
) )
.await?; .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?; let (msg_id, chat_id, chat_type) = msg?;
set_msg_failed(context, msg_id, error.as_ref()).await;
if i == 0 {
// Add only one info msg for all failed messages // Add only one info msg for all failed messages
ndn_maybe_add_info_msg(context, failed, chat_id, chat_type).await?; ndn_maybe_add_info_msg(context, failed, chat_id, chat_type).await?;
} }
}
Ok(()) Ok(())
} }