mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-23 21:44:13 +01:00
Merge pull request #3287 from matrix-org/rav/allow_leaving_server_notices_room
Let users leave the server notice room after joining
This commit is contained in:
commit
41921ac01b
2 changed files with 19 additions and 12 deletions
|
@ -24,7 +24,10 @@ history; it will appear to have come from the 'server notices user' (see
|
||||||
below).
|
below).
|
||||||
|
|
||||||
The user is prevented from sending any messages in this room by the power
|
The user is prevented from sending any messages in this room by the power
|
||||||
levels. They also cannot leave it.
|
levels.
|
||||||
|
|
||||||
|
Having joined the room, the user can leave the room if they want. Subsequent
|
||||||
|
server notices will then cause a new room to be created.
|
||||||
|
|
||||||
Synapse configuration
|
Synapse configuration
|
||||||
---------------------
|
---------------------
|
||||||
|
|
|
@ -298,16 +298,6 @@ class RoomMemberHandler(object):
|
||||||
is_blocked = yield self.store.is_room_blocked(room_id)
|
is_blocked = yield self.store.is_room_blocked(room_id)
|
||||||
if is_blocked:
|
if is_blocked:
|
||||||
raise SynapseError(403, "This room has been blocked on this server")
|
raise SynapseError(403, "This room has been blocked on this server")
|
||||||
else:
|
|
||||||
# we don't allow people to reject invites to, or leave, the
|
|
||||||
# server notice room.
|
|
||||||
is_blocked = yield self._is_server_notice_room(room_id)
|
|
||||||
if is_blocked:
|
|
||||||
raise SynapseError(
|
|
||||||
http_client.FORBIDDEN,
|
|
||||||
"You cannot leave this room",
|
|
||||||
errcode=Codes.CANNOT_LEAVE_SERVER_NOTICE_ROOM,
|
|
||||||
)
|
|
||||||
|
|
||||||
if effective_membership_state == Membership.INVITE:
|
if effective_membership_state == Membership.INVITE:
|
||||||
# block any attempts to invite the server notices mxid
|
# block any attempts to invite the server notices mxid
|
||||||
|
@ -383,6 +373,20 @@ class RoomMemberHandler(object):
|
||||||
if same_sender and same_membership and same_content:
|
if same_sender and same_membership and same_content:
|
||||||
defer.returnValue(old_state)
|
defer.returnValue(old_state)
|
||||||
|
|
||||||
|
# we don't allow people to reject invites to the server notice
|
||||||
|
# room, but they can leave it once they are joined.
|
||||||
|
if (
|
||||||
|
old_membership == Membership.INVITE and
|
||||||
|
effective_membership_state == Membership.LEAVE
|
||||||
|
):
|
||||||
|
is_blocked = yield self._is_server_notice_room(room_id)
|
||||||
|
if is_blocked:
|
||||||
|
raise SynapseError(
|
||||||
|
http_client.FORBIDDEN,
|
||||||
|
"You cannot reject this invite",
|
||||||
|
errcode=Codes.CANNOT_LEAVE_SERVER_NOTICE_ROOM,
|
||||||
|
)
|
||||||
|
|
||||||
is_host_in_room = yield self._is_host_in_room(current_state_ids)
|
is_host_in_room = yield self._is_host_in_room(current_state_ids)
|
||||||
|
|
||||||
if effective_membership_state == Membership.JOIN:
|
if effective_membership_state == Membership.JOIN:
|
||||||
|
|
Loading…
Reference in a new issue