replace accidental unwraps with if let's
this provides not only some future compatibility with MSC4051, but it just makes sense to not crash/error if we can't get a server_name from the room ID and should just use the server_name from the sender user's invite event. there is already code ahead that accounts for an empty vector so this is safe. Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
81b8f7c380
commit
ca42ec338b
2 changed files with 15 additions and 4 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue