Skip to content

Commit fed3923

Browse files
committed
common: Add method to get the event id from a SyncRoomEvent
1 parent dc0ff26 commit fed3923

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/matrix-sdk-common/src/deserialized_responses.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ pub struct SyncRoomEvent {
9797
pub encryption_info: Option<EncryptionInfo>,
9898
}
9999

100+
impl SyncRoomEvent {
101+
/// Get the event id of this `SyncRoomEvent` if the event has any valid id.
102+
pub fn event_id(&self) -> Option<Box<EventId>> {
103+
self.event.get_field::<Box<EventId>>("event_id").ok().flatten()
104+
}
105+
}
106+
100107
impl From<Raw<AnySyncRoomEvent>> for SyncRoomEvent {
101108
fn from(inner: Raw<AnySyncRoomEvent>) -> Self {
102109
Self { encryption_info: None, event: inner }

0 commit comments

Comments
 (0)