mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-04-22 08:08:35 -04:00
feat: added beacon_info start event to the latest_event that can be displayed
This commit is contained in:
committed by
Ivan Enderlin
parent
a4bb2f3ff4
commit
cabaede7fc
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user