diff --git a/CHANGELOG.md b/CHANGELOG.md index 2029b9819..84c5b7cbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - add IMAP ID extension support #3468 - configure DeltaChat folder by selecting it, so it is configured even if not LISTed #3371 - build PyPy wheels #6683 +- improve default error if NDN does not provide an error #3456 ### Fixes - mailing list: remove square-brackets only for first name #3452 @@ -27,7 +28,7 @@ - limit the rate of webxdc update sending #3417 ### Fixes -- set a default error if NDN does not provide an error +- set a default error if NDN does not provide an error #3410 - python: avoid exceptions when messages/contacts/chats are compared with `None` - node: wait for the event loop to stop before destroying contexts #3431 #3451 - emit configuration errors via event on failure #3433 diff --git a/src/message.rs b/src/message.rs index 5d9741a12..5e8eaf18a 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1533,7 +1533,7 @@ pub async fn handle_mdn( pub(crate) async fn handle_ndn( context: &Context, failed: &FailureReport, - error: &str, + error: Option, ) -> Result<()> { if failed.rfc724_mid.is_empty() { return Ok(()); @@ -1564,10 +1564,18 @@ pub(crate) async fn handle_ndn( ) .await?; + let error = if let Some(error) = error { + error + } else if let Some(failed_recipient) = &failed.failed_recipient { + format!("Delivery to {} failed.", failed_recipient).clone() + } else { + "Delivery to at least one recipient failed.".to_string() + }; + let mut first = true; for msg in msgs.into_iter() { let (msg_id, chat_id, chat_type) = msg?; - set_msg_failed(context, msg_id, error).await; + set_msg_failed(context, msg_id, &error).await; if first { // Add only one info msg for all failed messages ndn_maybe_add_info_msg(context, failed, chat_id, chat_type).await?; diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 0ed618956..c055aae3a 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -1401,11 +1401,11 @@ impl MimeMessage { } if let Some(failure_report) = &self.failure_report { - let error = parts.iter().find(|p| p.typ == Viewtype::Text).map_or_else( - || "Non-Delivery-Notification without further details.".to_string(), - |p| p.msg.clone(), - ); - if let Err(e) = message::handle_ndn(context, failure_report, &error).await { + let error = parts + .iter() + .find(|p| p.typ == Viewtype::Text) + .map(|p| p.msg.clone()); + if let Err(e) = message::handle_ndn(context, failure_report, error).await { warn!(context, "Could not handle ndn: {}", e); } } diff --git a/src/receive_imf.rs b/src/receive_imf.rs index ec2e951c1..563e7b9d7 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -2647,7 +2647,7 @@ mod tests { "shenauithz@testrun.org", "Mr.un2NYERi1RM.lbQ5F9q-QyJ@tiscali.it", include_bytes!("../test-data/message/tiscali_ndn.eml"), - Some("Non-Delivery-Notification without further details."), + Some("Delivery to at least one recipient failed."), ) .await; }