Add an Admin API that removes a room from both public and AS room lists
This commit is contained in:
@@ -529,6 +529,21 @@ You will have to manually handle, if you so choose, the following:
|
||||
* Removal of the Content Violation room if desired.
|
||||
|
||||
|
||||
# Delist Room From Public Directory API
|
||||
|
||||
Allows delisting a room from both the public room directory and any application service-specific
|
||||
room lists. The room will still exist, but not be publicly visible. Note that this **does not**
|
||||
prevent room owners or application services from adding the room to public room lists again
|
||||
afterwards.
|
||||
|
||||
```
|
||||
DELETE /_synapse/admin/v1/rooms/directory/<room_id_or_alias>
|
||||
```
|
||||
|
||||
The room will be removed from both the public directory and any application service
|
||||
directories. The response body for a successful request is empty.
|
||||
|
||||
|
||||
# Make Room Admin API
|
||||
|
||||
Grants another user the highest power available to a local user who is in the room.
|
||||
|
||||
@@ -38,6 +38,7 @@ from synapse.rest.admin.media import ListMediaInRoom, register_servlets_for_medi
|
||||
from synapse.rest.admin.purge_room_servlet import PurgeRoomServlet
|
||||
from synapse.rest.admin.rooms import (
|
||||
DeleteRoomRestServlet,
|
||||
DelistRoomFromDirectoryRestServlet,
|
||||
ForwardExtremitiesRestServlet,
|
||||
JoinRoomAliasServlet,
|
||||
ListRoomRestServlet,
|
||||
@@ -214,6 +215,7 @@ def register_servlets(hs, http_server):
|
||||
Register all the admin servlets.
|
||||
"""
|
||||
register_servlets_for_client_rest_resource(hs, http_server)
|
||||
DelistRoomFromDirectoryRestServlet(hs).register(http_server)
|
||||
ListRoomRestServlet(hs).register(http_server)
|
||||
RoomStateRestServlet(hs).register(http_server)
|
||||
RoomRestServlet(hs).register(http_server)
|
||||
|
||||
@@ -192,6 +192,50 @@ class DeleteRoomRestServlet(RestServlet):
|
||||
return (200, ret)
|
||||
|
||||
|
||||
class DelistRoomFromDirectoryRestServlet(ResolveRoomIdMixin, RestServlet):
|
||||
"""Modifies both the the public room and application service directory listings
|
||||
for a room.
|
||||
"""
|
||||
|
||||
PATTERNS = admin_patterns("/rooms/directory/(?P<room_identifier>[^/]*)$")
|
||||
|
||||
def __init__(self, hs: "HomeServer"):
|
||||
super().__init__(hs)
|
||||
self.hs = hs
|
||||
self.auth = hs.get_auth()
|
||||
self.directory_handler = hs.get_directory_handler()
|
||||
|
||||
async def on_DELETE(
|
||||
self, request: SynapseRequest, room_identifier: str
|
||||
) -> Tuple[int, JsonDict]:
|
||||
"""Removes a room from both the public and appservice room directories by its ID
|
||||
|
||||
Args:
|
||||
request: The request.
|
||||
room_identifier: The ID of the room to remove, or an alias leading to it.
|
||||
|
||||
Returns:
|
||||
A tuple of status code, response JSON dict.
|
||||
"""
|
||||
requester = await self.auth.get_user_by_req(request)
|
||||
await assert_user_is_admin(self.auth, requester.user)
|
||||
|
||||
# Get the ID of the room if an alias was provided
|
||||
room_id, _ = await self.resolve_room_id(room_identifier)
|
||||
|
||||
# Remove the room from the public room directory
|
||||
await self.directory_handler.edit_published_room_list(
|
||||
requester, room_id, "private"
|
||||
)
|
||||
|
||||
# Remove the room from all application-service public room directories
|
||||
await self.directory_handler.remove_room_from_published_appservice_room_list(
|
||||
room_id
|
||||
)
|
||||
|
||||
return 200, {}
|
||||
|
||||
|
||||
class ListRoomRestServlet(RestServlet):
|
||||
"""
|
||||
List all rooms that are known to the homeserver. Results are returned
|
||||
|
||||
Reference in New Issue
Block a user