From 77eec1b73ff5881ef9d5ee837fdb0ccbd1a3a5bb Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 26 Jun 2025 16:41:18 +0100 Subject: [PATCH] Improve pre-join state handling in `join_room_by_id_or_alias` --- crates/matrix-sdk/src/client/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index c419ef65e..aeb1af5ab 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -1526,11 +1526,22 @@ impl Client { alias: &RoomOrAliasId, server_names: &[OwnedServerName], ) -> Result { + let pre_join_info = { + match alias.try_into() { + Ok(room_id) => self.prepare_join_room_by_id(room_id).await, + Err(_) => { + // The id is a room alias. We assume (possibly incorrectly?) that we are not + // responding to an invitation to the room, and therefore don't need to handle + // things that happen as a result of invites. + None + } + } + }; let request = assign!(join_room_by_id_or_alias::v3::Request::new(alias.to_owned()), { via: server_names.to_owned(), }); let response = self.send(request).await?; - self.finish_join_room(&response.room_id, None).await + self.finish_join_room(&response.room_id, pre_join_info).await } /// Search the homeserver's directory of public rooms.