From 49e5461ef75d6c65cb32ef94344149f18eeb0974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 30 Nov 2023 13:17:30 +0100 Subject: [PATCH] Add a method to check if we have a room key stored locally --- crates/matrix-sdk-crypto/src/machine.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/matrix-sdk-crypto/src/machine.rs b/crates/matrix-sdk-crypto/src/machine.rs index 3bb063374..96a70f8a9 100644 --- a/crates/matrix-sdk-crypto/src/machine.rs +++ b/crates/matrix-sdk-crypto/src/machine.rs @@ -1535,6 +1535,16 @@ impl OlmMachine { result } + /// Do we have the room key for the given room and with the given session id + /// in the store? + pub async fn is_room_key_available( + &self, + room_id: &RoomId, + session_id: &str, + ) -> Result { + Ok(self.store().get_inbound_group_session(room_id, session_id).await?.is_some()) + } + /// Get encryption info for a decrypted timeline event. /// /// This recalculates the [`EncryptionInfo`] data that is returned by