Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
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
1 change: 1 addition & 0 deletions changelog.d/16677.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore `encryption_enabled_by_default_for_room_type` setting when creating server notices room, since the notices will be send unencrypted anyway.
8 changes: 7 additions & 1 deletion synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ async def create_room(
config: JsonDict,
ratelimit: bool = True,
creator_join_profile: Optional[JsonDict] = None,
ignore_forced_encryption: bool = False,
) -> Tuple[str, Optional[RoomAlias], int]:
"""Creates a new room.

Expand All @@ -714,6 +715,8 @@ async def create_room(
derived from the user's profile. If set, should contain the
values to go in the body of the 'join' event (typically
`avatar_url` and/or `displayname`.
ignore_forced_encryption:
Ignore encryption forced by `encryption_enabled_by_default_for_room_type` setting.

Returns:
A 3-tuple containing:
Expand Down Expand Up @@ -1015,6 +1018,7 @@ async def _send_events_for_new_room(
room_alias: Optional[RoomAlias] = None,
power_level_content_override: Optional[JsonDict] = None,
creator_join_profile: Optional[JsonDict] = None,
ignore_forced_encryption: bool = False,
) -> Tuple[int, str, int]:
"""Sends the initial events into a new room. Sends the room creation, membership,
and power level events into the room sequentially, then creates and batches up the
Expand Down Expand Up @@ -1049,6 +1053,8 @@ async def _send_events_for_new_room(
creator_join_profile:
Set to override the displayname and avatar for the creating
user in this room.
ignore_forced_encryption:
Ignore encryption forced by `encryption_enabled_by_default_for_room_type` setting.

Returns:
A tuple containing the stream ID, event ID and depth of the last
Expand Down Expand Up @@ -1251,7 +1257,7 @@ async def create_event(
)
events_to_send.append((event, context))

if config["encrypted"]:
if config["encrypted"] and not ignore_forced_encryption:
encryption_event, encryption_context = await create_event(
EventTypes.RoomEncryption,
{"algorithm": RoomEncryptionAlgorithms.DEFAULT},
Expand Down
3 changes: 3 additions & 0 deletions synapse/server_notices/server_notices_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ async def get_or_create_notice_room_for_user(self, user_id: str) -> str:
"avatar_url": self._config.servernotices.server_notices_mxid_avatar_url,
}

# `ignore_forced_encryption` is used to bypass `encryption_enabled_by_default_for_room_type`
# setting if it set, since the server notices will not be encrypted anyway.
room_id, _, _ = await self._room_creation_handler.create_room(
requester,
config={
Expand All @@ -187,6 +189,7 @@ async def get_or_create_notice_room_for_user(self, user_id: str) -> str:
},
ratelimit=False,
creator_join_profile=join_profile,
ignore_forced_encryption=True,
)

self.maybe_get_notice_room_for_user.invalidate((user_id,))
Expand Down