From ac153c80d5810b622e4d17979844f16fe2914dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 24 Nov 2021 14:11:56 +0100 Subject: [PATCH] rust: Expose a method to check if a user is tracked --- rust-sdk/src/machine.rs | 9 +++++++++ rust-sdk/src/olm.udl | 2 ++ 2 files changed, 11 insertions(+) diff --git a/rust-sdk/src/machine.rs b/rust-sdk/src/machine.rs index 7581c2b4e7..c250d0d8e5 100644 --- a/rust-sdk/src/machine.rs +++ b/rust-sdk/src/machine.rs @@ -387,6 +387,15 @@ impl OlmMachine { .block_on(self.inner.update_tracked_users(users.iter())); } + /// Check if the given user is considered to be tracked. + /// + /// A user can be marked for tracking using the + /// [`OlmMachine::update_tracked_users()`] method. + pub fn is_user_tracked(&self, user_id: &str) -> Result { + let user_id = UserId::try_from(user_id)?; + Ok(self.inner.tracked_users().contains(&user_id)) + } + /// Generate one-time key claiming requests for all the users we are missing /// sessions for. /// diff --git a/rust-sdk/src/olm.udl b/rust-sdk/src/olm.udl index 2590afbed7..894d9afe3c 100644 --- a/rust-sdk/src/olm.udl +++ b/rust-sdk/src/olm.udl @@ -271,6 +271,8 @@ interface OlmMachine { [Throws=CryptoStoreError] sequence get_user_devices([ByRef] string user_id); + [Throws=CryptoStoreError] + boolean is_user_tracked([ByRef] string user_id); void update_tracked_users(sequence users); [Throws=CryptoStoreError] Request? get_missing_sessions(sequence users);