mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
feat: Don't put text into post-message (#7714)
Before this PR, when a user with current main sends a large message to a user with an old Delta Chat (before #7431), the text will be duplicated: One message will arrive with only the text, and one message with attachment+text. This PR changes this - there will be one message with only the text, and one message with only the attachment. If we want to guard against lost pre-messages, then we can revert this PR in a few months, though I'm not sure that's necessary - it's unlikely that the small pre-message gets lost but the big post-message gets through.
This commit is contained in:
@@ -1872,19 +1872,23 @@ impl MimeFactory {
|
|||||||
|
|
||||||
let footer = if is_reaction { "" } else { &self.selfstatus };
|
let footer = if is_reaction { "" } else { &self.selfstatus };
|
||||||
|
|
||||||
let message_text = format!(
|
let message_text = if self.pre_message_mode == PreMessageMode::Post {
|
||||||
"{}{}{}{}{}{}",
|
"".to_string()
|
||||||
fwdhint.unwrap_or_default(),
|
} else {
|
||||||
quoted_text.unwrap_or_default(),
|
format!(
|
||||||
escape_message_footer_marks(final_text),
|
"{}{}{}{}{}{}",
|
||||||
if !final_text.is_empty() && !footer.is_empty() {
|
fwdhint.unwrap_or_default(),
|
||||||
"\r\n\r\n"
|
quoted_text.unwrap_or_default(),
|
||||||
} else {
|
escape_message_footer_marks(final_text),
|
||||||
""
|
if !final_text.is_empty() && !footer.is_empty() {
|
||||||
},
|
"\r\n\r\n"
|
||||||
if !footer.is_empty() { "-- \r\n" } else { "" },
|
} else {
|
||||||
footer
|
""
|
||||||
);
|
},
|
||||||
|
if !footer.is_empty() { "-- \r\n" } else { "" },
|
||||||
|
footer
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let mut main_part = MimePart::new("text/plain", message_text);
|
let mut main_part = MimePart::new("text/plain", message_text);
|
||||||
if is_reaction {
|
if is_reaction {
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ async fn test_out_of_order_receiving() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_msg_text_on_lost_pre_msg() -> Result<()> {
|
async fn test_lost_pre_msg() -> Result<()> {
|
||||||
let mut tcm = TestContextManager::new();
|
let mut tcm = TestContextManager::new();
|
||||||
let alice = &tcm.alice().await;
|
let alice = &tcm.alice().await;
|
||||||
let bob = &tcm.bob().await;
|
let bob = &tcm.bob().await;
|
||||||
@@ -144,7 +144,7 @@ async fn test_msg_text_on_lost_pre_msg() -> Result<()> {
|
|||||||
let _pre_msg = alice.pop_sent_msg().await;
|
let _pre_msg = alice.pop_sent_msg().await;
|
||||||
let msg = bob.recv_msg(&full_msg).await;
|
let msg = bob.recv_msg(&full_msg).await;
|
||||||
assert_eq!(msg.download_state, DownloadState::Done);
|
assert_eq!(msg.download_state, DownloadState::Done);
|
||||||
assert_eq!(msg.text, "populate");
|
assert_eq!(msg.text, "");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user