Skip to content

Commit 9f72e2c

Browse files
committed
sdk: Add room::Joined::room_keys_received_stream
1 parent 04d5613 commit 9f72e2c

File tree

1 file changed

+20
-1
lines changed
  • crates/matrix-sdk/src/room/joined

1 file changed

+20
-1
lines changed

crates/matrix-sdk/src/room/joined/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use std::{borrow::Borrow, ops::Deref};
44

55
use eyeball::shared::Observable as SharedObservable;
66
#[cfg(feature = "e2e-encryption")]
7-
use matrix_sdk_base::RoomMemberships;
7+
use futures_core::Stream;
8+
#[cfg(feature = "e2e-encryption")]
9+
use matrix_sdk_base::{crypto::store::RoomKeyInfo, RoomMemberships};
810
use matrix_sdk_common::instant::{Duration, Instant};
911
use mime::{self, Mime};
1012
use ruma::{
@@ -440,6 +442,23 @@ impl Joined {
440442
Ok(())
441443
}
442444

445+
/// Receive notifications of a room keys for this room being received.
446+
///
447+
/// Each time a room key for this room is updated in any way, an update will
448+
/// be sent to the stream. Updates that happen at the same time are
449+
/// batched into a [`Vec`].
450+
///
451+
/// If the reader of the stream lags too far behind, a warning will be
452+
/// logged and items will be dropped.
453+
#[cfg(feature = "e2e-encryption")]
454+
pub async fn room_keys_received_stream(&self) -> impl Stream<Item = Vec<RoomKeyInfo>> {
455+
self.client
456+
.encryption()
457+
.room_keys_for_room_received_stream(self.room_id())
458+
.await
459+
.expect("OlmMachine must be set up before a room::Joined object is created")
460+
}
461+
443462
/// Wait for the room to be fully synced.
444463
///
445464
/// This method makes sure the room that was returned when joining a room

0 commit comments

Comments
 (0)