summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Kösters <timo@koesters.xyz>2023-08-09 22:21:21 +0200
committerTimo Kösters <timo@koesters.xyz>2023-08-09 22:21:21 +0200
commit183558150d1c2a022b9be60b22295f78d2326b27 (patch)
tree3b69086f8353aa734bfba0e4e4ec4a72d57cda3f
parentc028e0553c541d954b50f82f8ea058c43d8b7d22 (diff)
downloadconduit-183558150d1c2a022b9be60b22295f78d2326b27.zip
fix: don't show removed rooms in space
-rw-r--r--src/service/rooms/spaces/mod.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/service/rooms/spaces/mod.rs b/src/service/rooms/spaces/mod.rs
index 9b57d53..53232f4 100644
--- a/src/service/rooms/spaces/mod.rs
+++ b/src/service/rooms/spaces/mod.rs
@@ -19,6 +19,7 @@ use ruma::{
join_rules::{self, AllowRule, JoinRule, RoomJoinRulesEventContent},
topic::RoomTopicEventContent,
},
+ space::child::SpaceChildEventContent,
StateEventType,
},
space::SpaceRoomJoinRule,
@@ -124,11 +125,24 @@ impl Service {
if event_type != StateEventType::SpaceChild {
continue;
}
+
+ let pdu = services()
+ .rooms
+ .timeline
+ .get_pdu(&id)?
+ .ok_or_else(|| Error::bad_database("Event in space state not found"))?;
+
+ if serde_json::from_str::<SpaceChildEventContent>(pdu.content.get())
+ .ok()
+ .and_then(|c| c.via)
+ .map_or(true, |v| v.is_empty())
+ {
+ continue;
+ }
+
if let Ok(room_id) = OwnedRoomId::try_from(state_key) {
children_ids.push(room_id);
- children_pdus.push(services().rooms.timeline.get_pdu(&id)?.ok_or_else(
- || Error::bad_database("Event in space state not found"),
- )?);
+ children_pdus.push(pdu);
}
}