From 15d7deddb8f6b30c16b4c58f24cd44c4e919c071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 12 Aug 2020 15:15:50 +0200 Subject: [PATCH] matrix-sdk: Only claim one-time keys if we're also going to share group sessions. --- matrix_sdk/src/client.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index 26ab5126..6b417068 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -1007,20 +1007,6 @@ impl Client { }; if encrypted { - let missing_sessions = { - let room = self.base_client.get_joined_room(room_id).await; - let room = room.as_ref().unwrap().read().await; - let members = room - .joined_members - .keys() - .chain(room.invited_members.keys()); - self.base_client.get_missing_sessions(members).await? - }; - - if !missing_sessions.is_empty() { - self.claim_one_time_keys(missing_sessions).await?; - } - if self.base_client.should_share_group_session(room_id).await { #[allow(clippy::map_clone)] if let Some(mutex) = self.group_session_locks.get(room_id).map(|m| m.clone()) { @@ -1036,6 +1022,20 @@ impl Client { let _guard = mutex.lock().await; + let missing_sessions = { + let room = self.base_client.get_joined_room(room_id).await; + let room = room.as_ref().unwrap().read().await; + let members = room + .joined_members + .keys() + .chain(room.invited_members.keys()); + self.base_client.get_missing_sessions(members).await? + }; + + if !missing_sessions.is_empty() { + self.claim_one_time_keys(missing_sessions).await?; + } + let response = self.share_group_session(room_id).await; self.group_session_locks.remove(room_id);