diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 55eeedf1c..f26102066 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -3040,6 +3040,60 @@ mod tests { assert_eq!(chat.name, "Atlas Obscura"); } + #[async_std::test] + async fn test_dhl_mailing_list() { + let t = TestContext::new_alice().await; + t.set_config(Config::ShowEmails, Some("2")).await.unwrap(); + + dc_receive_imf( + &t, + include_bytes!("../test-data/message/mailinglist_dhl.eml"), + "INBOX", + 1, + false, + ) + .await + .unwrap(); + let msg = t.get_last_msg().await; + assert_eq!( + msg.text, + Some("Ihr Paket ist in der Packstation 123 – bla bla".to_string()) + ); + assert!(msg.has_html()); + let chat = Chat::load_from_db(&t, msg.chat_id).await.unwrap(); + assert_eq!(chat.typ, Chattype::Mailinglist); + assert_eq!(chat.blocked, Blocked::Deaddrop); + assert_eq!(chat.grpid, "1234ABCD-123LMNO.mailing.dhl.de"); + assert_eq!(chat.name, "DHL Paket"); + } + + #[async_std::test] + async fn test_dpd_mailing_list() { + let t = TestContext::new_alice().await; + t.set_config(Config::ShowEmails, Some("2")).await.unwrap(); + + dc_receive_imf( + &t, + include_bytes!("../test-data/message/mailinglist_dpd.eml"), + "INBOX", + 1, + false, + ) + .await + .unwrap(); + let msg = t.get_last_msg().await; + assert_eq!( + msg.text, + Some("Bald ist Ihr DPD Paket da – bla bla".to_string()) + ); + assert!(msg.has_html()); + let chat = Chat::load_from_db(&t, msg.chat_id).await.unwrap(); + assert_eq!(chat.typ, Chattype::Mailinglist); + assert_eq!(chat.blocked, Blocked::Deaddrop); + assert_eq!(chat.grpid, "dpdde.mxmail.service.dpd.de"); + assert_eq!(chat.name, "DPD"); + } + #[async_std::test] async fn test_dont_show_tokens_in_contacts_list() { check_dont_show_in_contacts_list( diff --git a/test-data/message/mailinglist_dhl.eml b/test-data/message/mailinglist_dhl.eml new file mode 100644 index 000000000..ec80d54ea --- /dev/null +++ b/test-data/message/mailinglist_dhl.eml @@ -0,0 +1,52 @@ +Return-Path: +X-Original-To: alice@example.org +Delivered-To: m1234567@dd12345.kasserver.com +Received: from mail23-52.srv2.de (mail23-52.srv2.de [12.123.12.12]) + by dd12345.kasserver.com (Postfix) with ESMTPS id 123456789000 + for ; Fri, 26 Feb 2021 13:52:22 +0100 (CET) +Message-ID: <123456789.1234567.1234567891234@rnd-17.broadmail.live> +MIME-Version: 1.0 +Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; + boundary="----=_Part_1234567_123456789.1614343941878" +Date: Fri, 26 Feb 2021 13:52:21 +0100 (CET) +From: DHL Paket +Reply-To: DHL Paket +To: alice@example.org +Subject: Ihr Paket ist in der Packstation 123 +X-ulpe: re-1234567890x57b7k6dveEHmqr-1234SULP-123M6T60-123J47@mailing.dhl.de +List-Id: <1234ABCD-123LMNO.mailing.dhl.de> +X-Report-Spam: complaints@episerver.com +X-CSA-Complaints: csa-complaints@eco.de +List-Unsubscribe: , +List-Unsubscribe-Post: List-Unsubscribe=One-Click +mkaTechnicalID: 59630749051 +Feedback-ID: 1CZ4Z7YB:349M6T60:episerver + +------=_Part_1234567_123456789.1614343941878 +Content-Type: multipart/alternative; + boundary="----=_Part_2345678_234567890.1614343941876" + +------=_Part_2345678_234567890.1614343941876 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +bla bla +------=_Part_2345678_234567890.1614343941876 +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +bla bla! +------=_Part_2345678_234567890.1614343941876-- + +------=_Part_1234567_123456789.1614343941878 +Content-Type: application/pkcs7-signature; name=smime.p7s; smime-type=signed-data +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="smime.p7s" +Content-Description: S/MIME Cryptographic Signature + +MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCAMIIE +2TCCA8GgAwIBAgIQAZqdBKdhliD9nM3n971RjjANBgkqhkiG9w0BAQsFADBDMQswCQYDVQQGEwJE +... +------=_Part_1234567_123456789.1614343941878-- diff --git a/test-data/message/mailinglist_dpd.eml b/test-data/message/mailinglist_dpd.eml new file mode 100644 index 000000000..64af2bb60 --- /dev/null +++ b/test-data/message/mailinglist_dpd.eml @@ -0,0 +1,30 @@ +Return-Path: +X-Original-To: alice@example.org +Delivered-To: m1234567@dd12345.kasserver.com +Received: from inxmx185.inxserver.de (inxmx185.inxserver.de [12.123.123.123]) + by dd12345.kasserver.com (Postfix) with ESMTPS id 1234567C6F00 + for ; Thu, 25 Feb 2021 18:22:22 +0100 (CET) +X-Inx-Account: dpdde@mx-auth +IronPort-SDR: Eg4123456789012345678901234567890OBl6dSxiUIClsmw6YinLT8n0waG/Xj8Spgcape6JP + mLzNAfcaDruw== +X-IronPort-AV: E=Sophos;i="5.81,206,1234567000"; + d="scan'208,217";a="123456782" +From: DPD +To: alice@example.org +Message-ID: +Subject: Bald ist Ihr DPD Paket da +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_1234567_1234567890.1234567890123" +Date: Thu, 25 Feb 2021 18:22:21 +0100 (CET) +List-Help: +List-Id: +X-CSA-Complaints: csa-complaints@eco.de +Feedback-ID: xcom-dpdde-mx:xcom-dpdde:mx:inxmailde + +------=_Part_1234567_1234567890.1234567890123 +Content-Type: text/html; charset=utf-8 +Content-Transfer-Encoding: quoted-printable + +bla bla +------=_Part_1234567_1234567890.1234567890123--