matrix-sdk: Only claim one-time keys if we're also going to share group sessions.

master
Damir Jelić 2020-08-12 15:15:50 +02:00
parent 18e597aa79
commit 15d7deddb8
1 changed files with 14 additions and 14 deletions

View File

@ -1007,20 +1007,6 @@ impl Client {
}; };
if encrypted { 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 { if self.base_client.should_share_group_session(room_id).await {
#[allow(clippy::map_clone)] #[allow(clippy::map_clone)]
if let Some(mutex) = self.group_session_locks.get(room_id).map(|m| m.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 _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; let response = self.share_group_session(room_id).await;
self.group_session_locks.remove(room_id); self.group_session_locks.remove(room_id);