From 609df21271f94563c0b03b98669177442daa9c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 9 Apr 2020 16:29:03 +0200 Subject: [PATCH] async_client: Add a method to share room keys. --- src/async_client.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/async_client.rs b/src/async_client.rs index 828a1663..f7327e66 100644 --- a/src/async_client.rs +++ b/src/async_client.rs @@ -720,6 +720,35 @@ impl AsyncClient { Ok(response) } + /// Share a group session for a room. + /// + /// # Arguments + /// + /// * `room_id` - The ID of the room for which we want to share a group + /// session. + /// + /// # Panics + /// + /// Panics if the client isn't logged in. + #[cfg(feature = "encryption")] + #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + #[instrument] + async fn share_group_session(&self, room_id: &RoomId) -> Result<()> { + let mut requests = self + .base_client + .read() + .await + .share_group_session(room_id) + .await + .expect("Keys don't need to be uploaded"); + + for request in requests.drain(..) { + let response: send_event_to_device::Response = self.send(request).await?; + } + + Ok(()) + } + /// Upload the E2E encryption keys. /// /// This uploads the long lived device keys as well as the required amount