Skip to content

Commit 837e416

Browse files
committed
fixup! sdk: add Room::share_history
1 parent fa2f58f commit 837e416

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

crates/matrix-sdk/src/room/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,10 +1807,6 @@ impl Room {
18071807
/// Share any shareable E2EE history in this room with the given recipient,
18081808
/// as per [MSC4268].
18091809
///
1810-
/// # Panics
1811-
///
1812-
/// Panics if the OlmMachine hasn't been set up on the client.
1813-
///
18141810
/// [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268
18151811
#[cfg(feature = "e2e-encryption")]
18161812
#[instrument(skip_all, fields(room_id = ?self.room_id(), ?user_id))]

crates/matrix-sdk/src/room/shared_room_history.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ use std::iter;
1616

1717
use ruma::OwnedUserId;
1818

19-
use crate::{crypto::types::events::room_key_bundle::RoomKeyBundleContent, Result, Room};
19+
use crate::{crypto::types::events::room_key_bundle::RoomKeyBundleContent, Error, Result, Room};
2020

2121
/// Share any shareable E2EE history in the given room with the given recipient,
2222
/// as per [MSC4268].
2323
///
24-
/// # Panics
25-
///
26-
/// Panics if the OlmMachine hasn't been set up on the client.
27-
///
2824
/// [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268
2925
pub async fn share_room_history(room: &Room, user_id: OwnedUserId) -> Result<()> {
3026
tracing::info!("Sharing message history in {} with {}", room.room_id(), user_id);
@@ -33,8 +29,7 @@ pub async fn share_room_history(room: &Room, user_id: OwnedUserId) -> Result<()>
3329
// 1. Construct the key bundle
3430
let bundle = {
3531
let olm_machine = client.olm_machine().await;
36-
let olm_machine =
37-
olm_machine.as_ref().expect("This should only be called once we have an OlmMachine");
32+
let olm_machine = olm_machine.as_ref().ok_or(Error::NoOlmMachine)?;
3833
olm_machine.store().build_room_key_bundle(room.room_id()).await?
3934
};
4035

0 commit comments

Comments
 (0)