diff --git a/src/base_client.rs b/src/base_client.rs index 677214cf..12164686 100644 --- a/src/base_client.rs +++ b/src/base_client.rs @@ -399,6 +399,25 @@ impl Client { } } + /// Should the client share a group session for the given room. + /// + /// Returns true if a session needs to be shared before room messages can be + /// encrypted, false if one is already shared and ready to encrypt room + /// messages. + /// + /// This should be called every time a new room message wants to be sent out + /// since group sessions can expire at any time. + #[cfg(feature = "encryption")] + #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + pub async fn should_share_group_session(&self, room_id: &RoomId) -> bool { + let olm = self.olm.lock().await; + + match &*olm { + Some(o) => o.should_share_group_session(room_id), + None => false, + } + } + /// Should users be queried for their device keys. #[cfg(feature = "encryption")] #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))]