crytpo: Change the share_group_session method to always create a new session.

master
Damir Jelić 2020-04-10 11:45:50 +02:00
parent 1504b3a02a
commit 0a2b66de9a
2 changed files with 3 additions and 13 deletions

View File

@ -442,7 +442,7 @@ impl Client {
Some(o) => {
let room = room.lock().await;
let members = room.members.keys();
Ok(o.share_megolm_session(room_id, members).await?)
Ok(o.share_group_session(room_id, members).await?)
}
None => panic!("Olm machine wasn't started"),
}

View File

@ -920,7 +920,7 @@ impl OlmMachine {
}
// TODO accept an algorithm here
pub(crate) async fn share_megolm_session<'a, I>(
pub(crate) async fn share_group_session<'a, I>(
&mut self,
room_id: &RoomId,
users: I,
@ -928,19 +928,9 @@ impl OlmMachine {
where
I: IntoIterator<Item = &'a UserId>,
{
if !self.outbound_group_session.contains_key(room_id) {
self.create_outbound_group_session(room_id).await?
}
self.create_outbound_group_session(room_id).await?;
let megolm_session = self.outbound_group_session.get(room_id).unwrap();
let megolm_session = if megolm_session.expired() {
self.create_outbound_group_session(room_id).await?;
self.outbound_group_session.get(room_id).unwrap()
} else {
megolm_session
};
if megolm_session.shared() {
panic!("Session is already shared");
}