diff --git a/crates/matrix-sdk-base/src/client.rs b/crates/matrix-sdk-base/src/client.rs index ff086f96c..df920c5a0 100644 --- a/crates/matrix-sdk-base/src/client.rs +++ b/crates/matrix-sdk-base/src/client.rs @@ -1071,7 +1071,7 @@ impl BaseClient { content: impl MessageLikeEventContent, ) -> Result { match self.olm_machine().await { - Some(o) => Ok(o.encrypt(room_id, content).await?), + Some(o) => Ok(o.encrypt_room_event(room_id, content).await?), None => panic!("Olm machine wasn't started"), } } diff --git a/crates/matrix-sdk-crypto-ffi/src/machine.rs b/crates/matrix-sdk-crypto-ffi/src/machine.rs index b895bb9c6..fbd01ee4f 100644 --- a/crates/matrix-sdk-crypto-ffi/src/machine.rs +++ b/crates/matrix-sdk-crypto-ffi/src/machine.rs @@ -523,7 +523,7 @@ impl OlmMachine { let content = AnyMessageLikeEventContent::from_parts(event_type, &content)?; let encrypted_content = self .runtime - .block_on(self.inner.encrypt(&room_id, content)) + .block_on(self.inner.encrypt_room_event(&room_id, content)) .expect("Encrypting an event produced an error"); Ok(serde_json::to_string(&encrypted_content)?) diff --git a/crates/matrix-sdk-crypto/src/machine.rs b/crates/matrix-sdk-crypto/src/machine.rs index 1d79ef5a7..ee2880d03 100644 --- a/crates/matrix-sdk-crypto/src/machine.rs +++ b/crates/matrix-sdk-crypto/src/machine.rs @@ -651,21 +651,21 @@ impl OlmMachine { /// Panics if a group session for the given room wasn't shared beforehand. /// /// [`share_group_session`]: Self::share_group_session - pub async fn encrypt( + pub async fn encrypt_room_event( &self, room_id: &RoomId, content: impl MessageLikeEventContent, ) -> MegolmResult { let event_type = content.event_type().to_string(); let content = serde_json::to_value(&content)?; - - self.group_session_manager.encrypt(room_id, content, &event_type).await + self.encrypt_room_event_raw(room_id, content, &event_type).await } /// Encrypt a json [`Value`] content for the given room. /// - /// This method is equivalent to the [`encrypt()`] method but operates on an - /// arbitrary JSON value instead of strongly-typed event content struct. + /// This method is equivalent to the [`OlmMachine::encrypt_room_event()`] + /// method but operates on an arbitrary JSON value instead of strongly-typed + /// event content struct. /// /// # Arguments /// @@ -680,9 +680,7 @@ impl OlmMachine { /// # Panics /// /// Panics if a group session for the given room wasn't shared beforehand. - /// - /// [`encrypt()`]: #method.encrypt - pub async fn encrypt_raw( + pub async fn encrypt_room_event_raw( &self, room_id: &RoomId, content: Value, @@ -1957,7 +1955,7 @@ pub(crate) mod tests { let content = RoomMessageEventContent::text_plain(plaintext); let encrypted_content = alice - .encrypt(room_id, AnyMessageLikeEventContent::RoomMessage(content.clone())) + .encrypt_room_event(room_id, AnyMessageLikeEventContent::RoomMessage(content.clone())) .await .unwrap(); diff --git a/crates/matrix-sdk/src/room/joined.rs b/crates/matrix-sdk/src/room/joined.rs index d9592f6e1..b65455119 100644 --- a/crates/matrix-sdk/src/room/joined.rs +++ b/crates/matrix-sdk/src/room/joined.rs @@ -575,7 +575,7 @@ impl Joined { let olm = self.client.olm_machine().await.expect("Olm machine wasn't started"); let encrypted_content = - olm.encrypt_raw(self.inner.room_id(), content, event_type).await?; + olm.encrypt_room_event_raw(self.inner.room_id(), content, event_type).await?; let raw_content = Raw::new(&encrypted_content) .expect("Failed to serialize encrypted event") .cast();