From cabaede7fc374763adb46321e853bfe4b68075fe Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Mon, 16 Mar 2026 16:46:27 +0100 Subject: [PATCH] feat: added beacon_info start event to the latest_event that can be displayed --- .../src/latest_events/latest_event/builder.rs | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/crates/matrix-sdk/src/latest_events/latest_event/builder.rs b/crates/matrix-sdk/src/latest_events/latest_event/builder.rs index 67fb90d3e..43dc79d6e 100644 --- a/crates/matrix-sdk/src/latest_events/latest_event/builder.rs +++ b/crates/matrix-sdk/src/latest_events/latest_event/builder.rs @@ -786,6 +786,15 @@ fn filter_any_sync_state_event( } } + // `org.matrix.msc3672.beacon_info` + // + // Only the *start* event (`is_live() == true`) is suitable. The stop + // event (`is_live() == false`) merely terminates the sharing session + // and should not appear as the room's latest event. + AnySyncStateEvent::BeaconInfo(SyncStateEvent::Original(beacon)) => { + if beacon.content.is_live() { filter_break() } else { filter_continue() } + } + _ => filter_continue(), } } @@ -1281,6 +1290,38 @@ mod filter_tests { ); } + #[test] + fn test_beacon_info_live() { + use std::time::Duration; + + // A live beacon_info (start of location sharing) is a candidate. + assert_latest_event_content!( + event | event_factory | { + event_factory + .beacon_info(None, Duration::from_secs(60), true, None) + .state_key(user_id!("@mnt_io:matrix.org")) + .into_event() + } + is a candidate + ); + } + + #[test] + fn test_beacon_info_stopped() { + use std::time::Duration; + + // A non-live beacon_info (stop event) is NOT a candidate. + assert_latest_event_content!( + event | event_factory | { + event_factory + .beacon_info(None, Duration::from_secs(60), false, None) + .state_key(user_id!("@mnt_io:matrix.org")) + .into_event() + } + is not a candidate + ); + } + #[test] fn test_room_message_verification_request() { use ruma::{OwnedDeviceId, events::room::message};