From 03c02133a2b2280714dcbe05ac4c23d11f3c9f3a Mon Sep 17 00:00:00 2001 From: Nyaaori <+@nyaaori.cat> Date: Sat, 15 Oct 2022 14:29:20 +0200 Subject: [PATCH] Cleanly handle invalid rooms on hierarchy endpoint --- src/api/client_server/space.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/client_server/space.rs b/src/api/client_server/space.rs index 0a7392e4..17bd5005 100644 --- a/src/api/client_server/space.rs +++ b/src/api/client_server/space.rs @@ -117,7 +117,9 @@ pub async fn get_hierarchy_route( if skip == 0 { if rooms_chunk.len() < limit { room_set.insert(room_id.clone()); - rooms_chunk.push(get_room_chunk(room_id, suggested_only, pdus).await?); + if let Ok(chunk) = get_room_chunk(room_id, suggested_only, pdus).await { + rooms_chunk.push(chunk) + }; } } else { skip -= 1; @@ -144,7 +146,7 @@ pub async fn get_hierarchy_route( async fn get_room_chunk( room_id: OwnedRoomId, suggested_only: bool, - phus: Vec>, + pdus: Vec>, ) -> Result { Ok(SpaceHierarchyRoomsChunk { canonical_alias: services() @@ -251,7 +253,7 @@ async fn get_room_chunk( }) .ok() .flatten(), - children_state: phus + children_state: pdus .into_iter() .flat_map(|pdu| { Some(HierarchySpaceChildEvent {