From 41fcebbcb0fc933df23f42760ca5a0579784e58b Mon Sep 17 00:00:00 2001 From: Skye Elliot Date: Thu, 21 Aug 2025 15:23:13 +0100 Subject: [PATCH] chore(sdk): Move `ensure_room_encryption_ready` to end of file --- crates/matrix-sdk/src/room/futures.rs | 37 ++++++++++++++------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/crates/matrix-sdk/src/room/futures.rs b/crates/matrix-sdk/src/room/futures.rs index 64add3391..0a1b23195 100644 --- a/crates/matrix-sdk/src/room/futures.rs +++ b/crates/matrix-sdk/src/room/futures.rs @@ -162,24 +162,6 @@ impl<'a> SendRawMessageLikeEvent<'a> { } } -/// Ensures the room is ready for encrypted events to be sent. -#[cfg(feature = "e2e-encryption")] -async fn ensure_room_encryption_ready(room: &Room) -> Result<()> { - if !room.are_members_synced() { - room.sync_members().await?; - } - - // Query keys in case we don't have them for newly synced members. - // - // Note we do it all the time, because we might have sync'd members before - // sending a message (so didn't enter the above branch), but - // could have not query their keys ever. - room.query_keys_for_untracked_or_dirty_users().await?; - room.preshare_room_key().await?; - - Ok(()) -} - impl<'a> IntoFuture for SendRawMessageLikeEvent<'a> { type Output = Result; boxed_into_future!(extra_bounds: 'a); @@ -520,3 +502,22 @@ impl<'a> IntoFuture for SendStateEvent<'a> { }) } } + +/// Ensures the room is ready for encrypted events to be sent. +#[cfg(feature = "e2e-encryption")] +async fn ensure_room_encryption_ready(room: &Room) -> Result<()> { + if !room.are_members_synced() { + room.sync_members().await?; + } + + // Query keys in case we don't have them for newly synced members. + // + // Note we do it all the time, because we might have sync'd members before + // sending a message (so didn't enter the above branch), but + // could have not query their keys ever. + room.query_keys_for_untracked_or_dirty_users().await?; + + room.preshare_room_key().await?; + + Ok(()) +}