fix: concat ndns (#6129)

close #2338

Concat error messages when receiving new ndns.
This PR adds a newline followed by the new NDN error to the error text.
Maybe we should use something more prominent like
```
-----------------------------------------------------------------------
```
or more newlines, but I'm not sure. This maybe has to be tested on a
real device to see what works best.
This commit is contained in:
Sebastian Klähn
2024-11-02 09:20:27 +01:00
committed by GitHub
parent 3292ba260d
commit dd73d23a0a
2 changed files with 59 additions and 1 deletions

View File

@@ -883,6 +883,54 @@ async fn test_parse_ndn_group_msg() -> Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_concat_multiple_ndns() -> Result<()> {
let t = TestContext::new().await;
t.configure_addr("alice@posteo.org").await;
let mid = "1234@mail.gmail.com";
receive_imf(
&t,
b"Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\
From: alice@posteo.org\n\
To: hanerthaertidiuea@gmx.de\n\
Subject: foo\n\
Message-ID: <1234@mail.gmail.com>\n\
Chat-Version: 1.0\n\
Chat-Disposition-Notification-To: alice@example.org\n\
Date: Sun, 22 Mar 2020 22:37:57 +0000\n\
\n\
hello\n",
false,
)
.await?;
let chats = Chatlist::try_load(&t, 0, None, None).await?;
let msg_id = chats.get_msg_id(0)?.unwrap();
let raw = include_str!("../../test-data/message/posteo_ndn.eml");
let raw = raw.replace(
"Message-ID: <04422840-f884-3e37-5778-8192fe22d8e1@posteo.de>",
&format!("Message-ID: <{}>", mid),
);
receive_imf(&t, raw.as_bytes(), false).await?;
let msg = Message::load_from_db(&t, msg_id).await?;
let err = "Undelivered Mail Returned to Sender This is the mail system at host mout01.posteo.de.\n\nI'm sorry to have to inform you that your message could not\nbe delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can\ndelete your own text from the attached returned message.\n\n The mail system\n\n<hanerthaertidiuea@gmx.de>: host mx01.emig.gmx.net[212.227.17.5] said: 550\n Requested action not taken: mailbox unavailable (in reply to RCPT TO\n command)".to_string();
assert_eq!(msg.error(), Some(err.clone()));
assert_eq!(msg.state, MessageState::OutFailed);
let raw = raw.replace(
"Message-Id: <20200609184422.DCB6B1200DD@mout01.posteo.de>",
"Message-Id: <next@mout01.posteo.de>",
);
receive_imf(&t, raw.as_bytes(), false).await?;
let msg = Message::load_from_db(&t, msg_id).await?;
assert_eq!(msg.error(), Some([err.clone(), err].join("\n\n")));
Ok(())
}
async fn load_imf_email(context: &Context, imf_raw: &[u8]) -> Message {
context
.set_config(Config::ShowEmails, Some("2"))