diff --git a/src/api/client_server/membership.rs b/src/api/client_server/membership.rs index 32ee1948..3d2ef5e7 100644 --- a/src/api/client_server/membership.rs +++ b/src/api/client_server/membership.rs @@ -73,7 +73,12 @@ pub async fn join_room_by_id_route( .map(|user| user.server_name().to_owned()), ); - servers.push(body.room_id.server_name().unwrap().into()); + // server names being permanently attached to room IDs may be potentally removed in the future (see MSC4051). + // for future compatibility with this, and just because it makes sense, we shouldn't fail if the room ID + // doesn't have a server name with it and just use at least the server name from the initial invite above + if let Some(server) = body.room_id.server_name() { + servers.push(server.into()); + } join_room_by_id_helper( body.sender_user.as_deref(), @@ -123,7 +128,12 @@ pub async fn join_room_by_id_or_alias_route( .map(|user| user.server_name().to_owned()), ); - servers.push(room_id.server_name().unwrap().into()); + // server names being permanently attached to room IDs may be potentally removed in the future (see MSC4051). + // for future compatibility with this, and just because it makes sense, we shouldn't fail if the room ID + // doesn't have a server name with it and just use at least the server name from the initial invite above + if let Some(server) = room_id.server_name() { + servers.push(server.into()); + } (servers, room_id) } diff --git a/src/service/rooms/spaces/mod.rs b/src/service/rooms/spaces/mod.rs index 677ba247..0174b48c 100644 --- a/src/service/rooms/spaces/mod.rs +++ b/src/service/rooms/spaces/mod.rs @@ -186,15 +186,16 @@ impl Service { if rooms_in_path.len() < max_depth { stack.push(children_ids); } - } else { - let server = current_room.server_name().unwrap(); + } else if let Some(server) = current_room.server_name() { if server == services().globals.server_name() { continue; } + if !results.is_empty() { // Early return so the client can see some data already break; } + debug!("Asking {server} for /hierarchy"); if let Ok(response) = services() .sending