mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 21:36:30 +03:00
test: test reception of multipart/alternative with text/calendar
In messages with text/plain, text/html and text/calendar parts within a multipart/alternative, text/calendar part is currently ignored, text/plain is displayed and HTML is available via HTML API.
This commit is contained in:
@@ -5557,3 +5557,29 @@ async fn test_lookup_key_contact_by_address_self() -> Result<()> {
|
|||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tests reception of multipart/alternative
|
||||||
|
/// with three parts, one of which is a calendar.
|
||||||
|
///
|
||||||
|
/// MS Exchange produces multipart/alternative
|
||||||
|
/// messages with three parts:
|
||||||
|
/// `text/plain`, `text/html` and `text/calendar`.
|
||||||
|
///
|
||||||
|
/// We display `text/plain` part in this case.
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_calendar_alternative() -> Result<()> {
|
||||||
|
let mut tcm = TestContextManager::new();
|
||||||
|
let t = &tcm.alice().await;
|
||||||
|
let raw = include_bytes!("../../test-data/message/calendar-alternative.eml");
|
||||||
|
let msg = receive_imf(t, raw, false).await?.unwrap();
|
||||||
|
assert_eq!(msg.msg_ids.len(), 1);
|
||||||
|
|
||||||
|
let text_msg = Message::load_from_db(t, msg.msg_ids[0]).await?;
|
||||||
|
assert_eq!(text_msg.text, "Subject was here – Hello!");
|
||||||
|
assert_eq!(text_msg.viewtype, Viewtype::Text);
|
||||||
|
assert!(text_msg.has_html());
|
||||||
|
let html = text_msg.get_id().get_html(t).await.unwrap().unwrap();
|
||||||
|
assert_eq!(html, "<b>Hello!</b>");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
30
test-data/message/calendar-alternative.eml
Normal file
30
test-data/message/calendar-alternative.eml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
From: Bob <bob@example.net>
|
||||||
|
To: Alice <alice@example.org>
|
||||||
|
Subject: Subject was here
|
||||||
|
Date: Mon, 11 Aug 2025 10:15:52 +0000
|
||||||
|
Message-ID:
|
||||||
|
<DU2PR10MB7741CB7551F025C98CE1B0C0EE28A@DU2PR10MB7741.EURPRD10.PROD.OUTLOOK.COM>
|
||||||
|
Content-Type: multipart/alternative;
|
||||||
|
boundary="_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_"
|
||||||
|
MIME-Version: 1.0
|
||||||
|
|
||||||
|
--_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_
|
||||||
|
Content-Type: text/plain; charset="utf-8"
|
||||||
|
|
||||||
|
Hello!
|
||||||
|
--_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_
|
||||||
|
Content-Type: text/html; charset="utf-8"
|
||||||
|
|
||||||
|
<b>Hello!</b>
|
||||||
|
--_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_
|
||||||
|
Content-Type: text/calendar; charset="utf-8"; method=REQUEST
|
||||||
|
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
METHOD:REQUEST
|
||||||
|
PRODID:Microsoft Exchange Server 2010
|
||||||
|
VERSION:2.0
|
||||||
|
...
|
||||||
|
END:VCALENDAR
|
||||||
|
|
||||||
|
--_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_--
|
||||||
|
|
||||||
Reference in New Issue
Block a user