Skip to content

Commit 2420934

Browse files
committed
fixup! sdk: send out the to-device requests created by Room::share_history
1 parent 95f1328 commit 2420934

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

crates/matrix-sdk-base/src/client.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,22 +1135,6 @@ impl BaseClient {
11351135
}
11361136
}
11371137

1138-
/// Get to-device requests that will share the details of a room key history
1139-
/// bundle with a user.
1140-
#[cfg(feature = "e2e-encryption")]
1141-
pub async fn share_room_key_bundle_data(
1142-
&self,
1143-
user_id: &UserId,
1144-
bundle_data: RoomKeyBundleContent,
1145-
) -> Result<Vec<ToDeviceRequest>> {
1146-
let olm = self.olm_machine().await;
1147-
let olm = olm.as_ref().expect("Olm machine wasn't started");
1148-
1149-
Ok(olm
1150-
.share_room_key_bundle_data(user_id, &self.room_key_recipient_strategy, bundle_data)
1151-
.await?)
1152-
}
1153-
11541138
/// Get the room with the given room id.
11551139
///
11561140
/// # Arguments

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub async fn share_room_history(room: &Room, user_id: OwnedUserId) -> Result<()>
4141
// 2. Upload to the server as an encrypted file
4242
let json = serde_json::to_vec(&bundle)?;
4343
let upload =
44-
room.client.upload_encrypted_file(&mime::APPLICATION_JSON, &mut (json.as_slice())).await?;
44+
client.upload_encrypted_file(&mime::APPLICATION_JSON, &mut (json.as_slice())).await?;
4545

4646
tracing::info!(
4747
media_url = ?upload.url,
@@ -54,13 +54,18 @@ pub async fn share_room_history(room: &Room, user_id: OwnedUserId) -> Result<()>
5454
client.claim_one_time_keys(iter::once(user_id.as_ref())).await?;
5555

5656
// 4. Send to-device messages to the recipient to share the keys.
57-
let requests = client
58-
.base_client()
59-
.share_room_key_bundle_data(
60-
&user_id,
61-
RoomKeyBundleContent { room_id: room.room_id().to_owned(), file: upload },
62-
)
63-
.await?;
57+
let content = RoomKeyBundleContent { room_id: room.room_id().to_owned(), file: upload };
58+
let requests = {
59+
let olm_machine = client.olm_machine().await;
60+
let olm_machine = olm_machine.as_ref().ok_or(Error::NoOlmMachine)?;
61+
olm_machine
62+
.share_room_key_bundle_data(
63+
&user_id,
64+
&client.base_client().room_key_recipient_strategy,
65+
content,
66+
)
67+
.await?
68+
};
6469

6570
for request in requests {
6671
let response = client.send_to_device(&request).await?;

0 commit comments

Comments
 (0)