fix(spaces): Honour suggested_only when listing children_state

This commit is contained in:
Erwan Leboucher
2026-08-24 23:59:17 +00:00
committed by Ellis Git
parent 224710e0fb
commit 2d633a5ee1
2 changed files with 8 additions and 4 deletions
@@ -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.
+7 -4
View File
@@ -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<Raw<HierarchySpaceChildEvent>> {
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;
}