From 2d633a5ee1208f69cf58af2cf3e2d2a780a787b2 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Mon, 24 Aug 2026 16:44:10 +0200 Subject: [PATCH] fix(spaces): Honour suggested_only when listing children_state --- changelog.d/+space-suggested-only.bugfix.md | 1 + src/service/rooms/summary/mod.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 changelog.d/+space-suggested-only.bugfix.md diff --git a/changelog.d/+space-suggested-only.bugfix.md b/changelog.d/+space-suggested-only.bugfix.md new file mode 100644 index 000000000..4949f1f31 --- /dev/null +++ b/changelog.d/+space-suggested-only.bugfix.md @@ -0,0 +1 @@ +Fixed the space hierarchy endpoints returning non-suggested `m.space.child` events in `children_state` when `suggested_only` was requested. Contributed by @eleboucher. diff --git a/src/service/rooms/summary/mod.rs b/src/service/rooms/summary/mod.rs index ca8afccde..4789deac8 100644 --- a/src/service/rooms/summary/mod.rs +++ b/src/service/rooms/summary/mod.rs @@ -127,7 +127,7 @@ async fn get_room_summary_and_children_for_user( let (mut summary, inaccessible_children) = { if let Some(summary) = self.build_local_room_summary(room_id).await { // We have this room locally. - let children_state = self.get_space_child_events(room_id).await; + let children_state = self.get_space_child_events(room_id, suggested_only).await; // All of the room's children are accessible to this server (because we have the // full room and its state), although some of them may not be accessible to @@ -315,7 +315,7 @@ pub async fn get_local_room_summary_for_server( } let children_state = if matches!(summary.room_type.as_ref(), Some(RoomType::Space)) { - self.get_space_child_events(room_id).await + self.get_space_child_events(room_id, suggested_only).await } else { vec![] }; @@ -324,8 +324,6 @@ pub async fn get_local_room_summary_for_server( .iter() // Ignore deserialization failures .flat_map(Raw::deserialize) - // Filter out non-suggested children if suggested_only is set - .filter(|child| !suggested_only || child.content.suggested) // Fetch summaries for the children in parallel .stream() .broad_then(async |child| { @@ -490,6 +488,7 @@ async fn fetch_remote_summary( async fn get_space_child_events( &self, room_id: &RoomId, + suggested_only: bool, ) -> Vec> { let current_shortstatehash = self .services @@ -518,6 +517,10 @@ async fn get_space_child_events( return None; } + if suggested_only && !content.suggested { + return None; + } + if RoomId::parse(&state_key).is_err() { return None; }