mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Trash location.kml messages
Assign location.kml message parts to the trash chat,
but return non-trash chat_id so locations are assigned
to the correct chat.
Due to a bug introduced in
7968f55191
previously location.kml messages resulted in
empty message bubbles on the receiver.
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
- Make sure, videochat-room-names are always URL-safe #3231
|
- Make sure, videochat-room-names are always URL-safe #3231
|
||||||
- Try removing account folder multiple times in case of failure #3229
|
- Try removing account folder multiple times in case of failure #3229
|
||||||
- Ignore messages from all spam folders if there are many #3246
|
- Ignore messages from all spam folders if there are many #3246
|
||||||
|
- Hide location-only messages instead of displaying empty bubbles #3248
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
|
|||||||
@@ -1103,11 +1103,11 @@ INSERT INTO msgs
|
|||||||
|
|
||||||
// If you change which information is skipped if the message is trashed,
|
// If you change which information is skipped if the message is trashed,
|
||||||
// also change `MsgId::trash()` and `delete_expired_messages()`
|
// also change `MsgId::trash()` and `delete_expired_messages()`
|
||||||
let trash = chat_id.is_trash();
|
let trash = chat_id.is_trash() || (location_kml_is && msg.is_empty());
|
||||||
|
|
||||||
stmt.execute(paramsv![
|
stmt.execute(paramsv![
|
||||||
rfc724_mid,
|
rfc724_mid,
|
||||||
chat_id,
|
if trash { DC_CHAT_ID_TRASH } else { chat_id },
|
||||||
if trash { ContactId::UNDEFINED } else { from_id },
|
if trash { ContactId::UNDEFINED } else { from_id },
|
||||||
if trash { ContactId::UNDEFINED } else { to_id },
|
if trash { ContactId::UNDEFINED } else { to_id },
|
||||||
sort_timestamp,
|
sort_timestamp,
|
||||||
|
|||||||
@@ -755,6 +755,7 @@ mod tests {
|
|||||||
#![allow(clippy::indexing_slicing)]
|
#![allow(clippy::indexing_slicing)]
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::dc_receive_imf::dc_receive_imf;
|
||||||
use crate::test_utils::TestContext;
|
use crate::test_utils::TestContext;
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
@@ -815,4 +816,68 @@ mod tests {
|
|||||||
assert!(!is_marker(" "));
|
assert!(!is_marker(" "));
|
||||||
assert!(!is_marker("\t"));
|
assert!(!is_marker("\t"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tests that location.kml is hidden.
|
||||||
|
#[async_std::test]
|
||||||
|
async fn receive_location_kml() -> Result<()> {
|
||||||
|
let alice = TestContext::new_alice().await;
|
||||||
|
|
||||||
|
dc_receive_imf(
|
||||||
|
&alice,
|
||||||
|
br#"Subject: Hello
|
||||||
|
Message-ID: hello@example.net
|
||||||
|
To: Alice <alice@example.org>
|
||||||
|
From: Bob <bob@example.net>
|
||||||
|
Date: Mon, 20 Dec 2021 00:00:00 +0000
|
||||||
|
Chat-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=no
|
||||||
|
|
||||||
|
Text message."#,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
let received_msg = alice.get_last_msg().await;
|
||||||
|
assert_eq!(received_msg.text.unwrap(), "Text message.");
|
||||||
|
|
||||||
|
dc_receive_imf(
|
||||||
|
&alice,
|
||||||
|
br#"Subject: locations
|
||||||
|
MIME-Version: 1.0
|
||||||
|
To: <alice@example.org>
|
||||||
|
From: <bob@example.net>
|
||||||
|
Date: Tue, 21 Dec 2021 00:00:00 +0000
|
||||||
|
Chat-Version: 1.0
|
||||||
|
Message-ID: <foobar@example.net>
|
||||||
|
Content-Type: multipart/mixed; boundary="U8BOG8qNXfB0GgLiQ3PKUjlvdIuLRF"
|
||||||
|
|
||||||
|
|
||||||
|
--U8BOG8qNXfB0GgLiQ3PKUjlvdIuLRF
|
||||||
|
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=no
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--U8BOG8qNXfB0GgLiQ3PKUjlvdIuLRF
|
||||||
|
Content-Type: application/vnd.google-earth.kml+xml
|
||||||
|
Content-Disposition: attachment; filename="location.kml"
|
||||||
|
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||||
|
<Document addr="bob@example.net">
|
||||||
|
<Placemark><Timestamp><when>2021-11-21T00:00:00Z</when></Timestamp><Point><coordinates accuracy="1.0000000000000000">10.00000000000000,20.00000000000000</coordinates></Point></Placemark>
|
||||||
|
</Document>
|
||||||
|
</kml>
|
||||||
|
|
||||||
|
--U8BOG8qNXfB0GgLiQ3PKUjlvdIuLRF--"#,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
// Received location message is not visible, last message stays the same.
|
||||||
|
let received_msg2 = alice.get_last_msg().await;
|
||||||
|
assert_eq!(received_msg2.id, received_msg.id);
|
||||||
|
|
||||||
|
let locations = get_range(&alice, None, None, 0, 0).await?;
|
||||||
|
assert_eq!(locations.len(), 1);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user