-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Render "message" parts in multipart messages' HTML (#4462)
This fixes the HTML display of messages containing forwarded messages. Before, forwarded messages weren't rendered in HTML and if a forwarded message is long and therefore truncated in the chat, it could only be seen in the "Message Info". In #4462 it was suggested to display "Show Full Message..." for each truncated message part and save to `msgs.mime_headers` only the corresponding part, but this is a quite huge change and refactoring and also it may be good that currently we save the full message structure to `msgs.mime_headers`, so i'd suggest not to change this for now.
- Loading branch information
Showing
2 changed files
with
89 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3834,30 +3834,51 @@ async fn test_big_forwarded_with_big_attachment() -> Result<()> { | |
let raw = include_bytes!("../../test-data/message/big_forwarded_with_big_attachment.eml"); | ||
let rcvd = receive_imf(t, raw, false).await?.unwrap(); | ||
assert_eq!(rcvd.msg_ids.len(), 3); | ||
|
||
let msg = Message::load_from_db(t, rcvd.msg_ids[0]).await?; | ||
assert_eq!(msg.get_viewtype(), Viewtype::Text); | ||
assert_eq!(msg.get_text(), "Hello!"); | ||
// Wrong: the second bubble's text is truncated, but "Show Full Message..." is going to be shown | ||
// in the first message bubble in the UIs. | ||
assert_eq!( | ||
msg.id | ||
.get_html(t) | ||
.await? | ||
.unwrap() | ||
.matches("Hello!") | ||
.count(), | ||
1 | ||
); | ||
assert!(!msg.has_html()); | ||
|
||
let msg = Message::load_from_db(t, rcvd.msg_ids[1]).await?; | ||
assert_eq!(msg.get_viewtype(), Viewtype::Text); | ||
assert!(msg.get_text().starts_with("this text with 42 chars is just repeated.")); | ||
assert!(msg | ||
.get_text() | ||
.starts_with("this text with 42 chars is just repeated.")); | ||
assert!(msg.get_text().ends_with("[...]")); | ||
// Wrong: the text is truncated, but it's not possible to see the full text in HTML. | ||
assert!(!msg.has_html()); | ||
|
||
let msg = Message::load_from_db(t, rcvd.msg_ids[2]).await?; | ||
assert_eq!(msg.get_viewtype(), Viewtype::File); | ||
assert!(!msg.has_html()); | ||
|
||
assert!(msg.has_html()); | ||
let html = msg.id.get_html(t).await?.unwrap(); | ||
let tail = html | ||
.split_once("Hello!") | ||
.unwrap() | ||
.1 | ||
.split_once("From: AAA") | ||
.unwrap() | ||
.1 | ||
.split_once("[email protected]") | ||
.unwrap() | ||
.1 | ||
.split_once("To: Alice") | ||
.unwrap() | ||
.1 | ||
.split_once("[email protected]") | ||
.unwrap() | ||
.1 | ||
.split_once("Subject: Some subject") | ||
.unwrap() | ||
.1 | ||
.split_once("Date: Fri, 2 Jun 2023 12:29:17 +0000") | ||
.unwrap() | ||
.1; | ||
assert_eq!( | ||
tail.matches("this text with 42 chars is just repeated.") | ||
.count(), | ||
128 | ||
); | ||
Ok(()) | ||
} | ||
|
||
|