From 664d8c239ce01efc1a021cefe898d809132a996d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 14 Aug 2020 16:20:49 +0200 Subject: [PATCH] crypto: Don't share group sessions with blacklisted devices. --- matrix_sdk_crypto/src/device.rs | 9 ++++++++- matrix_sdk_crypto/src/machine.rs | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/matrix_sdk_crypto/src/device.rs b/matrix_sdk_crypto/src/device.rs index ce9e8ece..029703d8 100644 --- a/matrix_sdk_crypto/src/device.rs +++ b/matrix_sdk_crypto/src/device.rs @@ -131,11 +131,18 @@ impl Device { self.trust_state.load(Ordering::Relaxed) } - /// Is the device locally marked trusted. + /// Is the device locally marked as trusted. pub fn is_trusted(&self) -> bool { self.trust_state() == TrustState::Verified } + /// Is the device locally marked as blacklisted. + /// + /// Blacklisted devices won't receive any group sessions. + pub fn is_blacklisted(&self) -> bool { + self.trust_state() == TrustState::BlackListed + } + /// Set the trust state of the device to the given state. /// /// Note: This should only done in the cryptostore where the trust state can diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index 2176b2f4..d17c2bed 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -1014,7 +1014,9 @@ impl OlmMachine { for user_id in users { for device in self.store.get_user_devices(user_id).await?.devices() { - devices.push(device.clone()); + if !device.is_blacklisted() { + devices.push(device.clone()); + } } }