feat: Include predecessor and successor information in room list

This commit is contained in:
timedout
2026-05-26 14:30:35 -04:00
committed by Ginger
parent 4ffe321b6a
commit cef2260dc7
2 changed files with 18 additions and 0 deletions
+12
View File
@@ -11,6 +11,7 @@ use ruma::{
room::{ room::{
create::RoomCreateEventContent, create::RoomCreateEventContent,
encryption::PossiblyRedactedRoomEncryptionEventContent, encryption::PossiblyRedactedRoomEncryptionEventContent,
tombstone::PossiblyRedactedRoomTombstoneEventContent,
}, },
}, },
}; };
@@ -94,6 +95,7 @@ pub(crate) async fn list_rooms_route(
canonical_alias_event, canonical_alias_event,
join_rules_event, join_rules_event,
history_visibility_event, history_visibility_event,
tombstone_event,
) = join!( ) = join!(
services.rooms.metadata.is_banned(&room_id), services.rooms.metadata.is_banned(&room_id),
services.rooms.metadata.is_disabled(&room_id), services.rooms.metadata.is_disabled(&room_id),
@@ -143,6 +145,14 @@ pub(crate) async fn list_rooms_route(
&StateEventType::RoomHistoryVisibility, &StateEventType::RoomHistoryVisibility,
"" ""
), ),
services
.rooms
.state_accessor
.room_state_get_content::<PossiblyRedactedRoomTombstoneEventContent>(
&room_id,
&StateEventType::RoomTombstone,
""
),
); );
let Ok(create_event) = create_event else { let Ok(create_event) = create_event else {
return None; return None;
@@ -168,6 +178,8 @@ pub(crate) async fn list_rooms_route(
canonical_alias: canonical_alias_event.unwrap_or(None), canonical_alias: canonical_alias_event.unwrap_or(None),
join_rules: join_rules_event.unwrap_or(None), join_rules: join_rules_event.unwrap_or(None),
history_visibility: history_visibility_event.unwrap_or(None), history_visibility: history_visibility_event.unwrap_or(None),
predecessor: create_content.predecessor.map(|c| c.room_id),
successor: tombstone_event.map_or(None, |c| c.replacement_room),
}) })
}) })
.collect() .collect()
@@ -140,6 +140,12 @@ pub mod v1 {
/// is present. May be redacted. /// is present. May be redacted.
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
pub history_visibility: Option<PossiblyRedactedRoomHistoryVisibilityEventContent>, pub history_visibility: Option<PossiblyRedactedRoomHistoryVisibilityEventContent>,
/// The ID of the room which replaces this one, if any.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub successor: Option<OwnedRoomId>,
/// The ID of the room which preceded this one, if any.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub predecessor: Option<OwnedRoomId>,
} }
#[response] #[response]