diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 37f6f3e91..c0ab3ef2a 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -864,9 +864,10 @@ async fn add_parts( DC_CHAT_ID_TRASH }); - // Extract ephemeral timer from the message. - let mut ephemeral_timer = if let Some(value) = mime_parser.get_header(HeaderDef::EphemeralTimer) - { + // Extract ephemeral timer from the message or use the existing timer if the message is not fully downloaded. + let mut ephemeral_timer = if is_partial_download.is_some() { + chat_id.get_ephemeral_timer(context).await? + } else if let Some(value) = mime_parser.get_header(HeaderDef::EphemeralTimer) { match value.parse::() { Ok(timer) => timer, Err(err) => { diff --git a/src/download.rs b/src/download.rs index 6d6177afc..b0cb4c222 100644 --- a/src/download.rs +++ b/src/download.rs @@ -227,6 +227,7 @@ mod tests { use crate::chat::send_msg; use crate::constants::Viewtype; use crate::dc_receive_imf::dc_receive_imf_inner; + use crate::ephemeral::Timer; use crate::test_utils::TestContext; use num_traits::FromPrimitive; @@ -343,4 +344,40 @@ mod tests { Ok(()) } + + #[async_std::test] + async fn test_partial_download_and_ephemeral() -> Result<()> { + let t = TestContext::new_alice().await; + let chat_id = t + .create_chat_with_contact("bob", "bob@example.org") + .await + .id; + chat_id + .set_ephemeral_timer(&t, Timer::Enabled { duration: 60 }) + .await?; + + // download message from bob partially, this must not change the ephemeral timer + dc_receive_imf_inner( + &t, + b"From: Bob \n\ + To: Alice \n\ + Chat-Version: 1.0\n\ + Subject: subject\n\ + Message-ID: \n\ + Date: Sun, 14 Nov 2021 00:10:00 +0000\ + Content-Type: text/plain", + "INBOX", + 1, + false, + Some(100000), + false, + ) + .await?; + assert_eq!( + chat_id.get_ephemeral_timer(&t).await?, + Timer::Enabled { duration: 60 } + ); + + Ok(()) + } }