mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 06:14:57 -04:00
Allow admins to proactively block rooms (#11228)
Co-authored-by: Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
This commit is contained in:
parent
a19d01c3d9
commit
b6f4d122ef
6 changed files with 102 additions and 20 deletions
|
@ -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
|
||||
|
@ -239,9 +239,22 @@ class RoomRestServlet(RestServlet):
|
|||
|
||||
# Purge room
|
||||
if purge:
|
||||
await pagination_handler.purge_room(room_id, force=force_purge)
|
||||
try:
|
||||
await pagination_handler.purge_room(room_id, force=force_purge)
|
||||
except NotFoundError:
|
||||
if block:
|
||||
# We can block unknown rooms with this endpoint, in which case
|
||||
# a failed purge is expected.
|
||||
pass
|
||||
else:
|
||||
# But otherwise, we expect this purge to have succeeded.
|
||||
raise
|
||||
|
||||
return 200, ret
|
||||
# Cast safety: cast away the knowledge that this is a TypedDict.
|
||||
# See https://github.com/python/mypy/issues/4976#issuecomment-579883622
|
||||
# for some discussion on why this is necessary. Either way,
|
||||
# `ret` is an opaque dictionary blob as far as the rest of the app cares.
|
||||
return 200, cast(JsonDict, ret)
|
||||
|
||||
|
||||
class RoomMembersRestServlet(RestServlet):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue