From 1504b3a02afdee16ffb46f45e84dfe9d26736cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 10 Apr 2020 11:44:09 +0200 Subject: [PATCH] crypto: Change the encrypt method to not require to take mut self. --- src/crypto/machine.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/crypto/machine.rs b/src/crypto/machine.rs index 3fab333b..223f006a 100644 --- a/src/crypto/machine.rs +++ b/src/crypto/machine.rs @@ -819,25 +819,23 @@ impl OlmMachine { } pub async fn encrypt( - &mut self, + &self, room_id: &RoomId, content: MessageEventContent, ) -> Result { - if !self.outbound_group_session.contains_key(room_id) { - self.create_outbound_group_session(room_id).await? - } + let session = self.outbound_group_session.get(room_id); - let session = self.outbound_group_session.get(room_id).unwrap(); + let session = if let Some(s) = session { + s + } else { + panic!("Session wasn't created nor shared"); + }; if session.expired() { - todo!() + panic!("Session is expired"); } - // if !session.shared() { - // todo!() - // } - - let mut json_content = json!({ + let json_content = json!({ "content": content, "room_id": room_id, "type": EventType::RoomMessage,