From e66b9de92243dbb0706c37e22bf0e3c61a28aa3a Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 16 May 2024 19:36:39 +0000 Subject: [PATCH] fix: do not mark the message as seen if it has location.kml --- src/location.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++++ src/receive_imf.rs | 1 - 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/location.rs b/src/location.rs index 452f2c5cc..973385522 100644 --- a/src/location.rs +++ b/src/location.rs @@ -885,6 +885,7 @@ mod tests { use super::*; use crate::config::Config; + use crate::message::MessageState; use crate::receive_imf::receive_imf; use crate::test_utils::{TestContext, TestContextManager}; use crate::tools::SystemTime; @@ -1015,6 +1016,54 @@ Content-Disposition: attachment; filename="location.kml" Ok(()) } + /// Tests that `location.kml` is not hidden and not seen if it contains a message. + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn receive_visible_location_kml() -> Result<()> { + let alice = TestContext::new_alice().await; + + receive_imf( + &alice, + br#"Subject: locations +MIME-Version: 1.0 +To: +From: +Date: Tue, 21 Dec 2021 00:00:00 +0000 +Chat-Version: 1.0 +Message-ID: +Content-Type: multipart/mixed; boundary="U8BOG8qNXfB0GgLiQ3PKUjlvdIuLRF" + + +--U8BOG8qNXfB0GgLiQ3PKUjlvdIuLRF +Content-Type: text/plain; charset=utf-8; format=flowed; delsp=no + +Text message. + + +--U8BOG8qNXfB0GgLiQ3PKUjlvdIuLRF +Content-Type: application/vnd.google-earth.kml+xml +Content-Disposition: attachment; filename="location.kml" + + + + +2021-11-21T00:00:00Z10.00000000000000,20.00000000000000 + + + +--U8BOG8qNXfB0GgLiQ3PKUjlvdIuLRF--"#, + false, + ) + .await?; + + let received_msg = alice.get_last_msg().await; + assert_eq!(received_msg.text, "Text message."); + assert_eq!(received_msg.state, MessageState::InFresh); + + let locations = get_range(&alice, None, None, 0, 0).await?; + assert_eq!(locations.len(), 1); + Ok(()) + } + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_send_locations_to_chat() -> Result<()> { let alice = TestContext::new_alice().await; diff --git a/src/receive_imf.rs b/src/receive_imf.rs index d62aa163e..4a7cb8967 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1019,7 +1019,6 @@ async fn add_parts( || fetching_existing_messages || is_mdn || is_reaction - || is_location_kml || chat_id_blocked == Blocked::Yes { MessageState::InSeen