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

Let users leave the server notice room after joining #3287

Merged
merged 1 commit into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/server_notices.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Server Notices
channel whereby server administrators can send messages to users on the server.

They are used as part of communication of the server polices(see
[consent_tracking.md](consent_tracking.md)), however the intention is that
[consent_tracking.md](consent_tracking.md)), however the intention is that
they may also find a use for features such as "Message of the day".

This is a feature specific to Synapse, but it uses standard Matrix
Expand All @@ -24,7 +24,10 @@ history; it will appear to have come from the 'server notices user' (see
below).

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
---------------------
Expand Down
24 changes: 14 additions & 10 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,6 @@ def _update_membership(
is_blocked = yield self.store.is_room_blocked(room_id)
if is_blocked:
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:
# block any attempts to invite the server notices mxid
Expand Down Expand Up @@ -383,6 +373,20 @@ def _update_membership(
if same_sender and same_membership and same_content:
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it reasonable to have an errcode of CANNOT_LEAVE_SERVER_NOTICE_ROOM when it is about rejecting invites? Or just a mistake?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to stick with the error code we have, now that it has started to land in clients, even if it's slightly misleading.

)

is_host_in_room = yield self._is_host_in_room(current_state_ids)

if effective_membership_state == Membership.JOIN:
Expand Down