Expose tombstone status in room details (#19737)

Exposes `tombstoned` and `replacement_room` in room details on admin API
endpoint `GET /_synapse/admin/v1/rooms/<room_id>`. Resolves #18347
This commit is contained in:
Noah Markert
2026-04-30 14:37:40 +02:00
committed by GitHub
parent 8fc23aa665
commit 2e7019ebc8
4 changed files with 21 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Exposes `tombstoned` and `replacement_room` in room details on admin API endpoint `GET /_synapse/admin/v1/rooms/<room_id>`. Contributed by Noah Markert.
+6 -1
View File
@@ -308,6 +308,9 @@ The following fields are possible in the JSON response body:
If the room does not define a type, the value will be `null`.
* `forgotten` - Whether all local users have
[forgotten](https://spec.matrix.org/latest/client-server-api/#leaving-rooms) the room.
* `tombstoned` - Whether the room has been tombstoned (permanently closed).
* `replacement_room` - The room ID of the new room that users should join instead, if this room was tombstoned. Will be
`null` if the room has not been tombstoned, or if it was tombstoned without designating a successor room.
The API is:
@@ -337,7 +340,9 @@ A response body like the following is returned:
"history_visibility": "shared",
"state_events": 93534,
"room_type": "m.space",
"forgotten": false
"forgotten": false,
"tombstoned": false,
"replacement_room": null
}
```
+10
View File
@@ -367,6 +367,7 @@ class RoomRestServlet(RestServlet):
self.store = hs.get_datastores().main
self.room_shutdown_handler = hs.get_room_shutdown_handler()
self.pagination_handler = hs.get_pagination_handler()
self._storage_controllers = hs.get_storage_controllers()
async def on_GET(
self, request: SynapseRequest, room_id: str
@@ -383,6 +384,15 @@ class RoomRestServlet(RestServlet):
members
)
result["forgotten"] = await self.store.is_locally_forgotten_room(room_id)
tombstone_event = await self._storage_controllers.state.get_current_state_event(
room_id,
EventTypes.Tombstone,
"",
)
result["tombstoned"] = tombstone_event is not None
result["replacement_room"] = (
tombstone_event.content.get("replacement_room") if tombstone_event else None
)
return HTTPStatus.OK, result
+4
View File
@@ -2311,10 +2311,14 @@ class RoomTestCase(unittest.HomeserverTestCase):
self.assertIn("state_events", channel.json_body)
self.assertIn("room_type", channel.json_body)
self.assertIn("forgotten", channel.json_body)
self.assertIn("tombstoned", channel.json_body)
self.assertIn("replacement_room", channel.json_body)
self.assertEqual(room_id_1, channel.json_body["room_id"])
self.assertIs(True, channel.json_body["federatable"])
self.assertIs(True, channel.json_body["public"])
self.assertIs(False, channel.json_body["tombstoned"])
self.assertIs(None, channel.json_body["replacement_room"])
def test_single_room_devices(self) -> None:
"""Test that `joined_local_devices` can be requested correctly"""