diff options
author | Shay <hillerys@element.io> | 2024-05-01 09:45:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-01 17:45:17 +0100 |
commit | 37558d5e4cd22ec8f120d2c0fbb8c9842d6dd131 (patch) | |
tree | 936a8218629d8b1c976b8e5748bbb0aaf12e49cb /synapse/handlers | |
parent | Drop sphinx docs (#17073) (diff) | |
download | synapse-37558d5e4cd22ec8f120d2c0fbb8c9842d6dd131.tar.xz |
Add support for MSC3823 - Account Suspension (#17051)
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/room_member.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py index 601d37341b..655c78e150 100644 --- a/synapse/handlers/room_member.py +++ b/synapse/handlers/room_member.py @@ -752,6 +752,36 @@ class RoomMemberHandler(metaclass=abc.ABCMeta): and requester.user.to_string() == self._server_notices_mxid ) + requester_suspended = await self.store.get_user_suspended_status( + requester.user.to_string() + ) + if action == Membership.INVITE and requester_suspended: + raise SynapseError( + 403, + "Sending invites while account is suspended is not allowed.", + Codes.USER_ACCOUNT_SUSPENDED, + ) + + if target.to_string() != requester.user.to_string(): + target_suspended = await self.store.get_user_suspended_status( + target.to_string() + ) + else: + target_suspended = requester_suspended + + if action == Membership.JOIN and target_suspended: + raise SynapseError( + 403, + "Joining rooms while account is suspended is not allowed.", + Codes.USER_ACCOUNT_SUSPENDED, + ) + if action == Membership.KNOCK and target_suspended: + raise SynapseError( + 403, + "Knocking on rooms while account is suspended is not allowed.", + Codes.USER_ACCOUNT_SUSPENDED, + ) + if ( not self.allow_per_room_profiles and not is_requester_server_notices_user ) or requester.shadow_banned: |