Improve pre-join state handling in join_room_by_id_or_alias

This commit is contained in:
Richard van der Hoff
2025-06-26 16:41:18 +01:00
parent 2a9f1e3c90
commit 77eec1b73f

View File

@@ -1526,11 +1526,22 @@ impl Client {
alias: &RoomOrAliasId,
server_names: &[OwnedServerName],
) -> Result<Room> {
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.