fix: Emit MsgsChanged, not IncomingMsg, for messages only having special parts (#8157)

An example of such messages is location-only messages.

Co-authored-by: Hocuri <hocuri@gmx.de>
This commit is contained in:
iequidoo
2026-04-24 20:26:27 -03:00
committed by iequidoo
parent 4a16c0c3dd
commit 4d537544ef
3 changed files with 49 additions and 4 deletions

View File

@@ -871,7 +871,7 @@ mod tests {
use crate::config::Config;
use crate::message::MessageState;
use crate::receive_imf::receive_imf;
use crate::test_utils::{TestContext, TestContextManager};
use crate::test_utils::{ExpectedEvents, TestContext, TestContextManager};
use crate::tools::SystemTime;
#[test]
@@ -1103,6 +1103,9 @@ Content-Disposition: attachment; filename="location.kml"
.await?;
let alice_chat = alice.create_chat(bob).await;
// Bob needs the chat accepted so that "normal" messages from Alice trigger `IncomingMsg`.
// Location-only messages still must trigger `MsgsChanged`.
bob.create_chat(alice).await;
// Alice enables location streaming.
// Bob receives a message saying that Alice enabled location streaming.
@@ -1117,7 +1120,18 @@ Content-Disposition: attachment; filename="location.kml"
SystemTime::shift(Duration::from_secs(10));
delete_expired(alice, time()).await?;
maybe_send(alice).await?;
bob.evtracker.clear_events();
bob.recv_msg_opt(&alice.pop_sent_msg().await).await;
bob.evtracker
.get_matching_ex(
bob,
ExpectedEvents {
expected: |e| matches!(e, EventType::MsgsChanged { .. }),
unexpected: |e| matches!(e, EventType::IncomingMsg { .. }),
},
)
.await
.unwrap();
assert_eq!(get_range(alice, None, None, 0, 0).await?.len(), 1);
assert_eq!(get_range(bob, None, None, 0, 0).await?.len(), 1);