Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Allow admins to proactively block rooms #11228

Merged
merged 15 commits into from
Nov 9, 2021
11 changes: 10 additions & 1 deletion synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
Tuple,
)

from typing_extensions import TypedDict

from synapse.api.constants import (
EventContentFields,
EventTypes,
Expand Down Expand Up @@ -1274,6 +1276,13 @@ def get_current_key_for_room(self, room_id: str) -> Awaitable[str]:
return self.store.get_room_events_max_id(room_id)


class ShutdownRoomResponse(TypedDict):
kicked_users: List[str]
failed_to_kick_users: List[str]
local_aliases: List[str]
new_room_id: Optional[str]


class RoomShutdownHandler:

DEFAULT_MESSAGE = (
Expand All @@ -1299,7 +1308,7 @@ async def shutdown_room(
new_room_name: Optional[str] = None,
message: Optional[str] = None,
block: bool = False,
) -> dict:
) -> ShutdownRoomResponse:
"""
Shuts down a room. Moves all local users and room aliases automatically
to a new room if `new_room_user_id` is set. Otherwise local users only
Expand Down
6 changes: 4 additions & 2 deletions synapse/rest/admin/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
import logging
from http import HTTPStatus
from typing import TYPE_CHECKING, List, Optional, Tuple
from typing import TYPE_CHECKING, List, Optional, Tuple, cast
from urllib import parse as urlparse

from synapse.api.constants import EventTypes, JoinRules, Membership
Expand Down Expand Up @@ -241,7 +241,9 @@ async def _delete_room(
if purge:
await pagination_handler.purge_room(room_id, force=force_purge)

return 200, ret
# Cast safety: I'm casting away the knowledge that this is a TypedDict.
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
# `ret` is an opaque dictionary blob as far as the rest of the app cares.
return 200, cast(JsonDict, ret)


class RoomMembersRestServlet(RestServlet):
Expand Down