From 0a6f1d1ac2ed65f66814ce91e7d21e2aeb480057 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 23 Apr 2022 15:25:13 +0100 Subject: [PATCH 01/34] add default_power_level_content_override config option. Lets you override the default power levels for rooms created on this server, per room creation preset. Useful if you know that your users need special permissions in rooms that they create (e.g. to send particular types of state events without needing an elevated power level). This takes the same shape as the power_level_content_override parameter in the /createRoom API, but is applied before that parameter. This is something of a workaround in the absence of MSC3779 or MSC3761. --- synapse/config/room.py | 29 +++++++++++++++++++++++++++++ synapse/handlers/room.py | 12 ++++++++++++ 2 files changed, 41 insertions(+) diff --git a/synapse/config/room.py b/synapse/config/room.py index e18a87ea37f6..0ca0cfe93b2c 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -63,6 +63,19 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: "Invalid value for encryption_enabled_by_default_for_room_type" ) + self.default_power_level_content_override = config.get( + "default_power_level_content_override", + None, + ) + if self.default_power_level_content_override is not None: + for preset in self.default_power_level_content_override: + if preset not in vars(RoomCreationPreset).values(): + raise ConfigError( + "Unrecognised room preset %s in default_power_level_content_override" + % preset + ) + # We validate the actual overrides when we try to apply them. + def generate_config_section(self, **kwargs: Any) -> str: return """\ ## Rooms ## @@ -83,4 +96,20 @@ def generate_config_section(self, **kwargs: Any) -> str: # will also not affect rooms created by other servers. # #encryption_enabled_by_default_for_room_type: invite + + # Override the default power levels for rooms created on this server, per + # room creation preset. + # + # Useful if you know that your users need special permissions in rooms + # that they create (e.g. to send particular types of state events without + # needing an elevated power level). This takes the same shape as the + # `power_level_content_override` parameter in the /createRoom API, but + # is applied before that parameter. + # + # This is something of a workaround in the absence of MSC3779 or MSC3761. + # + #default_power_level_content_override: + # private_chat: null + # trusted_private_chat: null + # public_chat: null """ diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index b31f00b517a9..87dcb14acbb9 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -1046,6 +1046,18 @@ async def send(etype: str, content: JsonDict, **kwargs: Any) -> int: if power_level_content_override: power_level_content.update(power_level_content_override) + # override default_power_level_content_override for this room preset, if any + default_power_level_content_override = ( + self.config.room.default_power_level_content_override + ) + if ( + default_power_level_content_override + and default_power_level_content_override.get(preset_config) + ): + power_level_content.update( + default_power_level_content_override.get(preset_config) + ) + last_sent_stream_id = await send( etype=EventTypes.PowerLevels, content=power_level_content ) From 8cb9abe8e76c7e21f18560f1be603386268aff23 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 23 Apr 2022 15:36:41 +0100 Subject: [PATCH 02/34] changelog --- changelog.d/12535.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12535.feature diff --git a/changelog.d/12535.feature b/changelog.d/12535.feature new file mode 100644 index 000000000000..b345c58a67cc --- /dev/null +++ b/changelog.d/12535.feature @@ -0,0 +1 @@ +Add default_power_level_content_override config option. \ No newline at end of file From ba334669395af704da63027c9bc14e13b5ac825c Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 23 Apr 2022 15:39:41 +0100 Subject: [PATCH 03/34] update sample config --- docs/sample_config.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index b8d8c0dbf0a1..9502ddbe7816 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -2449,6 +2449,22 @@ push: # #encryption_enabled_by_default_for_room_type: invite +# Override the default power levels for rooms created on this server, per +# room creation preset. +# +# Useful if you know that your users need special permissions in rooms +# that they create (e.g. to send particular types of state events without +# needing an elevated power level). This takes the same shape as the +# `power_level_content_override` parameter in the /createRoom API, but +# is applied before that parameter. +# +# This is something of a workaround in the absence of MSC3779 or MSC3761. +# +#default_power_level_content_override: +# private_chat: null +# trusted_private_chat: null +# public_chat: null + # Uncomment to allow non-server-admin users to create groups on this server # From c3a8159299429cb4d44065b135f5deb9c39ead96 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 3 May 2022 15:38:08 +0100 Subject: [PATCH 04/34] Apply default_power_level_content_override before power_level_content_override --- synapse/handlers/room.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 87dcb14acbb9..0edbe03797e3 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -1040,12 +1040,6 @@ async def send(etype: str, content: JsonDict, **kwargs: Any) -> int: for invitee in invite_list: power_level_content["users"][invitee] = 100 - # Power levels overrides are defined per chat preset - power_level_content.update(config["power_level_content_override"]) - - if power_level_content_override: - power_level_content.update(power_level_content_override) - # override default_power_level_content_override for this room preset, if any default_power_level_content_override = ( self.config.room.default_power_level_content_override @@ -1058,6 +1052,12 @@ async def send(etype: str, content: JsonDict, **kwargs: Any) -> int: default_power_level_content_override.get(preset_config) ) + # Power levels overrides are defined per chat preset + power_level_content.update(config["power_level_content_override"]) + + if power_level_content_override: + power_level_content.update(power_level_content_override) + last_sent_stream_id = await send( etype=EventTypes.PowerLevels, content=power_level_content ) From 20e2a51c610c3651f8f413c79e2a8780ba7f7957 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 3 May 2022 15:39:13 +0100 Subject: [PATCH 05/34] Provide an example of a default_power_level_content_override --- synapse/config/room.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/config/room.py b/synapse/config/room.py index 0ca0cfe93b2c..bfebc4abfc91 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -109,7 +109,7 @@ def generate_config_section(self, **kwargs: Any) -> str: # This is something of a workaround in the absence of MSC3779 or MSC3761. # #default_power_level_content_override: - # private_chat: null + # private_chat: { "events": { "com.example.foo" : 0 } } # trusted_private_chat: null # public_chat: null """ From f7eed3af62490e438787c4cf3c3352f5ec6669a4 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 3 May 2022 15:48:01 +0100 Subject: [PATCH 06/34] Generate docs --- docs/sample_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index 4f71504af77d..f9d6bf842ef0 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -2467,7 +2467,7 @@ push: # This is something of a workaround in the absence of MSC3779 or MSC3761. # #default_power_level_content_override: -# private_chat: null +# private_chat: { "events": { "com.example.foo" : 0 } } # trusted_private_chat: null # public_chat: null From 7531942eeb853fa0fa208a82b76ea67a83e0895c Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 3 May 2022 15:57:04 +0100 Subject: [PATCH 07/34] Add a config manual entry for default_power_level_content_override --- .../configuration/config_documentation.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 968b0fbfaff4..93c54bc12d38 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -3284,6 +3284,27 @@ room_list_publication_rules: room_id: "*" action: allow ``` + +--- +Config option: `default_power_level_content_override` + +The `default_power_level_content_override` option controls the default power +levels for rooms. + +Useful if you know that your users need special permissions in rooms +that they create (e.g. to send particular types of state events without +needing an elevated power level). This takes the same shape as the +`power_level_content_override` parameter in the /createRoom API, but +is applied before that parameter. + +Example configuration: +```yaml +default_power_level_content_override: + private_chat: { "events": { "com.example.foo" : 0 } } + trusted_private_chat: null + public_chat: null +``` + --- ## Opentracing ## Configuration options related to Opentracing support. From 50b0b1eddf35ddf6a0b4cbb2c6ae959f7598a3ce Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 3 May 2022 17:20:29 +0100 Subject: [PATCH 08/34] Re-order room permissions config Order: preset, default from server config, specific from user --- synapse/handlers/room.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 0edbe03797e3..ceb8d44bd495 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -1040,7 +1040,12 @@ async def send(etype: str, content: JsonDict, **kwargs: Any) -> int: for invitee in invite_list: power_level_content["users"][invitee] = 100 - # override default_power_level_content_override for this room preset, if any + # If the user supplied a preset name e.g. "private_chat", + # we apply that preset + power_level_content.update(config["power_level_content_override"]) + + # If the server config contains default_power_level_content_override, + # and that contains information for this room preset, apply it. default_power_level_content_override = ( self.config.room.default_power_level_content_override ) @@ -1052,9 +1057,8 @@ async def send(etype: str, content: JsonDict, **kwargs: Any) -> int: default_power_level_content_override.get(preset_config) ) - # Power levels overrides are defined per chat preset - power_level_content.update(config["power_level_content_override"]) - + # Finally, if the user supplied specific permissions for this room, + # apply those. if power_level_content_override: power_level_content.update(power_level_content_override) From 9da3abc65f1253944b5df46a3e07051bbfb66ba8 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Wed, 4 May 2022 09:19:14 +0100 Subject: [PATCH 09/34] Move changelog file to correct name for this PR --- changelog.d/{12535.feature => 12618.feature} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{12535.feature => 12618.feature} (100%) diff --git a/changelog.d/12535.feature b/changelog.d/12618.feature similarity index 100% rename from changelog.d/12535.feature rename to changelog.d/12618.feature From 45da8d014cd3d8c1226c263d7fe905a106189741 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Wed, 4 May 2022 15:05:06 +0100 Subject: [PATCH 10/34] Tests for power level overrides --- tests/rest/client/test_rooms.py | 312 ++++++++++++++++++++++++++++++++ 1 file changed, 312 insertions(+) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index 9443daa0560a..a2ea82584f76 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -1116,6 +1116,318 @@ def test_rooms_messages_sent(self) -> None: self.assertEqual(200, channel.code, msg=channel.result["body"]) +class RoomPowerLevelOverridesTestCase(RoomBase): + """Tests that the power levels can be overridden with server config.""" + + user_id = "@sid1:red" + + servlets = [ + admin.register_servlets, + room.register_servlets, + login.register_servlets, + ] + + def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: + self.admin_user_id = self.register_user("admin", "pass") + self.admin_access_token = self.login("admin", "pass") + + def power_levels(self, room_id: str) -> Dict[str, Any]: + return self.helper.get_state( + room_id, "m.room.power_levels", self.admin_access_token + ) + + def test_default_power_levels_without_override(self) -> None: + room_id = self.helper.create_room_as(self.user_id) + self.assertEqual( + { + "ban": 50, + "events": { + "m.room.avatar": 50, + "m.room.canonical_alias": 50, + "m.room.encryption": 100, + "m.room.history_visibility": 100, + "m.room.name": 50, + "m.room.power_levels": 100, + "m.room.server_acl": 100, + "m.room.tombstone": 100, + }, + "events_default": 0, + "historical": 100, + "invite": 50, + "kick": 50, + "redact": 50, + "state_default": 50, + "users": {"@sid1:red": 100}, + "users_default": 0, + }, + self.power_levels(room_id), + ) + + def test_default_power_levels_with_room_override(self) -> None: + """ + Create a room, providing power level overrides. + Confirm that the room's power levels reflect the overrides. + + See https://github.com/matrix-org/matrix-spec/issues/492 + - currently we overwrite each key of power_level_content_override + completely. + """ + + room_id = self.helper.create_room_as( + self.user_id, + extra_content={ + "power_level_content_override": {"events": {"custom.event": 0}} + }, + ) + self.assertEqual( + { + "ban": 50, + "events": { + "custom.event": 0, + }, + "events_default": 0, + "historical": 100, + "invite": 50, + "kick": 50, + "redact": 50, + "state_default": 50, + "users": {"@sid1:red": 100}, + "users_default": 0, + }, + self.power_levels(room_id), + ) + + @unittest.override_config( + { + "default_power_level_content_override": { + "public_chat": {"events": {"custom.event": 0}}, + } + }, + ) + def test_power_levels_with_server_override(self) -> None: + """ + With a server configured to modify the room-level defaults, + Create a room, without providing any extra power level overrides. + Confirm that the room's power levels reflect the server-level overrides. + + Similar to https://github.com/matrix-org/matrix-spec/issues/492, + we overwrite each key of power_level_content_override completely. + """ + + room_id = self.helper.create_room_as(self.user_id) + self.assertEqual( + { + "ban": 50, + "events": { + "custom.event": 0, + }, + "events_default": 0, + "historical": 100, + "invite": 50, + "kick": 50, + "redact": 50, + "state_default": 50, + "users": {"@sid1:red": 100}, + "users_default": 0, + }, + self.power_levels(room_id), + ) + + @unittest.override_config( + { + "default_power_level_content_override": { + "public_chat": { + "events": {"server.event": 0}, + "ban": 13, + }, + } + }, + ) + def test_power_levels_with_server_and_room_overrides(self) -> None: + """ + With a server configured to modify the room-level defaults, + Create a room, providing different overrides. + Confirm that the room's power levels reflect both overrides, and + choose the room overrides where they clash. + """ + + room_id = self.helper.create_room_as( + self.user_id, + extra_content={ + "power_level_content_override": {"events": {"room.event": 0}} + }, + ) + + self.assertEqual( + { + "ban": 13, # From server config override + "events": { + "room.event": 0, # From room override + }, + "events_default": 0, + "historical": 100, + "invite": 50, + "kick": 50, + "redact": 50, + "state_default": 50, + "users": {"@sid1:red": 100}, + "users_default": 0, + }, + self.power_levels(room_id), + ) + + +class RoomPowerLevelOverridesInPracticeTestCase(RoomBase): + """Tests that we can really do various otherwise-prohibited actions + based on overriding the power levels in config.""" + + user_id = "@sid1:red" + + def test_creator_can_post_state_event(self) -> None: + # Given I am the creator of a room + room_id = self.helper.create_room_as(self.user_id) + + # When I send a state event + path = "/rooms/{room_id}/state/custom.event/my_state_key".format( + room_id=urlparse.quote(room_id), + ) + channel = self.make_request("PUT", path, "{}") + + # Then I am allowed + self.assertEqual(200, channel.code, msg=channel.result["body"]) + + def test_normal_user_can_not_post_state_event(self) -> None: + # Given I am a normal member of a room + room_id = self.helper.create_room_as("@some_other_guy:red") + self.helper.join(room=room_id, user=self.user_id) + + # When I send a state event + path = "/rooms/{room_id}/state/custom.event/my_state_key".format( + room_id=urlparse.quote(room_id), + ) + channel = self.make_request("PUT", path, "{}") + + # Then I am not allowed because state events require PL>=50 + self.assertEqual(403, channel.code, msg=channel.result["body"]) + self.assertEqual( + "You don't have permission to post that to the room. " + + "user_level (0) < send_level (50)", + channel.json_body["error"], + ) + + @unittest.override_config( + { + "default_power_level_content_override": { + "public_chat": {"events": {"custom.event": 0}}, + } + }, + ) + def test_with_config_override_normal_user_can_post_state_event(self) -> None: + # Given the server has config allowing normal users to post my event type + # And I am a normal member of a room + room_id = self.helper.create_room_as("@some_other_guy:red") + self.helper.join(room=room_id, user=self.user_id) + + # When I send a state event + path = "/rooms/{room_id}/state/custom.event/my_state_key".format( + room_id=urlparse.quote(room_id), + ) + channel = self.make_request("PUT", path, "{}") + + # Then I am allowed + self.assertEqual(200, channel.code, msg=channel.result["body"]) + + @unittest.override_config( + { + "default_power_level_content_override": { + "public_chat": {"events": {"custom.event": 0}}, + } + }, + ) + def test_any_room_override_defeats_config_override(self) -> None: + # Given the server has config allowing normal users to post my event type + # And I am a normal member of a room + # But the room was created with special permissions + extra_content: Dict[str, Any] = { + "power_level_content_override": {"events": {}}, + } + room_id = self.helper.create_room_as( + "@some_other_guy:red", extra_content=extra_content + ) + self.helper.join(room=room_id, user=self.user_id) + + # When I send a state event + path = "/rooms/{room_id}/state/custom.event/my_state_key".format( + room_id=urlparse.quote(room_id), + ) + channel = self.make_request("PUT", path, "{}") + + # Then I am not allowed + self.assertEqual(403, channel.code, msg=channel.result["body"]) + + @unittest.override_config( + { + "default_power_level_content_override": { + "public_chat": {"events": {"custom.event": 0}}, + } + }, + ) + def test_specific_room_override_defeats_config_override(self) -> None: + # Given the server has config allowing normal users to post my event type + # And I am a normal member of a room + # But the room was created with special permissions for this event type + extra_content = { + "power_level_content_override": {"events": {"custom.event": 1}}, + } + room_id = self.helper.create_room_as( + "@some_other_guy:red", extra_content=extra_content + ) + self.helper.join(room=room_id, user=self.user_id) + + # When I send a state event + path = "/rooms/{room_id}/state/custom.event/my_state_key".format( + room_id=urlparse.quote(room_id), + ) + channel = self.make_request("PUT", path, "{}") + + # Then I am not allowed + self.assertEqual(403, channel.code, msg=channel.result["body"]) + self.assertEqual( + "You don't have permission to post that to the room. " + + "user_level (0) < send_level (1)", + channel.json_body["error"], + ) + + @unittest.override_config( + { + "default_power_level_content_override": { + "public_chat": {"events": {"custom.event": 0}}, + } + }, + ) + def test_config_override_applies_only_to_specific_preset(self) -> None: + # Given the server has config for public_chats + # And I am a normal member of a private_chat room + room_id = self.helper.create_room_as("@some_other_guy:red", is_public=False) + self.helper.invite(room=room_id, src="@some_other_guy:red", targ=self.user_id) + self.helper.join(room=room_id, user=self.user_id) + + # When I send a state event + path = "/rooms/{room_id}/state/custom.event/my_state_key".format( + room_id=urlparse.quote(room_id), + ) + channel = self.make_request("PUT", path, "{}") + + # Then I am not allowed because the public_chat config does not + # affect this room, because this room is a private_chat + self.assertEqual(403, channel.code, msg=channel.result["body"]) + self.assertEqual( + "You don't have permission to post that to the room. " + + "user_level (0) < send_level (50)", + channel.json_body["error"], + ) + + class RoomInitialSyncTestCase(RoomBase): """Tests /rooms/$room_id/initialSync.""" From 0cb64bf694582439449d78fb7340540c80fab95a Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Wed, 4 May 2022 15:13:37 +0100 Subject: [PATCH 11/34] Update test config to match documentation --- tests/rest/client/test_rooms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index a2ea82584f76..240a2e68cddd 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -1402,6 +1402,8 @@ def test_specific_room_override_defeats_config_override(self) -> None: { "default_power_level_content_override": { "public_chat": {"events": {"custom.event": 0}}, + "private_chat": None, + "trusted_private_chat": None, } }, ) From f863ad9d436befc728c85ae824793969f53e9ac3 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Wed, 4 May 2022 15:18:23 +0100 Subject: [PATCH 12/34] Document the way power level overrides overwrite per key --- docs/usage/configuration/config_documentation.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 93c54bc12d38..914d1897fe40 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -3297,6 +3297,11 @@ needing an elevated power level). This takes the same shape as the `power_level_content_override` parameter in the /createRoom API, but is applied before that parameter. +Note that each key provided inside a preset (for example `events` in the example +below) will overwrite all existing defaults inside that key. So in the example +below, newly-created private_chat rooms will have no rules for any event types +except `com.example.foo`. + Example configuration: ```yaml default_power_level_content_override: From eba1ed412213d2ba03b96505a4726096fce932bb Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 6 May 2022 15:23:03 +0100 Subject: [PATCH 13/34] Reformat changelog for default_power_level_content_override Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> --- changelog.d/12618.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/12618.feature b/changelog.d/12618.feature index b345c58a67cc..08e414bfb9cb 100644 --- a/changelog.d/12618.feature +++ b/changelog.d/12618.feature @@ -1 +1 @@ -Add default_power_level_content_override config option. \ No newline at end of file +Add a `default_power_level_content_override` config option. \ No newline at end of file From 9d70d83dc837584eb16cf52784191c7e56c0ef22 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Mon, 9 May 2022 12:20:20 +0100 Subject: [PATCH 14/34] Explicitly mention that the config will be overlaid Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> --- synapse/config/room.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synapse/config/room.py b/synapse/config/room.py index bfebc4abfc91..9715272759e3 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -100,6 +100,9 @@ def generate_config_section(self, **kwargs: Any) -> str: # Override the default power levels for rooms created on this server, per # room creation preset. # + # The appropriate dictionary for the room preset will be applied on top + # of the existing power levels content. + # # Useful if you know that your users need special permissions in rooms # that they create (e.g. to send particular types of state events without # needing an elevated power level). This takes the same shape as the From e860ec69aca29b5f4b5cc905b190291d026a9e35 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Mon, 9 May 2022 12:23:31 +0100 Subject: [PATCH 15/34] Expand 12618 changelog entry --- changelog.d/12618.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/12618.feature b/changelog.d/12618.feature index 08e414bfb9cb..71639f9e1cbd 100644 --- a/changelog.d/12618.feature +++ b/changelog.d/12618.feature @@ -1 +1 @@ -Add a `default_power_level_content_override` config option. \ No newline at end of file +Add a `default_power_level_content_override` config option to set default room power levels. From 4309993a1156cdc8a2ef3cb40de8856cf56d8812 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Mon, 9 May 2022 12:23:57 +0100 Subject: [PATCH 16/34] Delete extranous sentence about MSC3779 and MSC3761 --- docs/sample_config.yaml | 2 -- synapse/config/room.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index f9d6bf842ef0..5361407b1f09 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -2464,8 +2464,6 @@ push: # `power_level_content_override` parameter in the /createRoom API, but # is applied before that parameter. # -# This is something of a workaround in the absence of MSC3779 or MSC3761. -# #default_power_level_content_override: # private_chat: { "events": { "com.example.foo" : 0 } } # trusted_private_chat: null diff --git a/synapse/config/room.py b/synapse/config/room.py index 9715272759e3..8cff01c795e7 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -109,8 +109,6 @@ def generate_config_section(self, **kwargs: Any) -> str: # `power_level_content_override` parameter in the /createRoom API, but # is applied before that parameter. # - # This is something of a workaround in the absence of MSC3779 or MSC3761. - # #default_power_level_content_override: # private_chat: { "events": { "com.example.foo" : 0 } } # trusted_private_chat: null From 3aed63a0ea2bdd1b062bfbbfe68e35c094d59401 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Mon, 9 May 2022 12:35:48 +0100 Subject: [PATCH 17/34] More realistic example for default_power_level_content_override --- docs/sample_config.yaml | 20 ++++++++++++++++---- synapse/config/room.py | 15 ++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index 5361407b1f09..5c2d46c92423 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -2465,10 +2465,22 @@ push: # is applied before that parameter. # #default_power_level_content_override: -# private_chat: { "events": { "com.example.foo" : 0 } } -# trusted_private_chat: null -# public_chat: null - +# private_chat: { +# "events": { +# "com.example.myeventtype" : 0, +# "m.room.avatar": 50, +# "m.room.canonical_alias": 50, +# "m.room.encryption": 100, +# "m.room.history_visibility": 100, +# "m.room.name": 50, +# "m.room.power_levels": 100, +# "m.room.server_acl": 100, +# "m.room.tombstone": 100 +# }, +# "events_default": 1 +# } +# trusted_private_chat: null +# public_chat: null # Uncomment to allow non-server-admin users to create groups on this server # diff --git a/synapse/config/room.py b/synapse/config/room.py index 8cff01c795e7..77221208cecb 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -110,7 +110,20 @@ def generate_config_section(self, **kwargs: Any) -> str: # is applied before that parameter. # #default_power_level_content_override: - # private_chat: { "events": { "com.example.foo" : 0 } } + # private_chat: { + # "events": { + # "com.example.myeventtype" : 0, + # "m.room.avatar": 50, + # "m.room.canonical_alias": 50, + # "m.room.encryption": 100, + # "m.room.history_visibility": 100, + # "m.room.name": 50, + # "m.room.power_levels": 100, + # "m.room.server_acl": 100, + # "m.room.tombstone": 100 + # }, + # "events_default": 1 + # } # trusted_private_chat: null # public_chat: null """ From 9c99926e3419a9dce773745d7f88c729f5952dbb Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 12:32:15 +0100 Subject: [PATCH 18/34] Fix indent of example config --- docs/sample_config.yaml | 4 ++++ synapse/config/room.py | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index 5c2d46c92423..71f9a725ebe2 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -2458,6 +2458,9 @@ push: # Override the default power levels for rooms created on this server, per # room creation preset. # +# The appropriate dictionary for the room preset will be applied on top +# of the existing power levels content. +# # Useful if you know that your users need special permissions in rooms # that they create (e.g. to send particular types of state events without # needing an elevated power level). This takes the same shape as the @@ -2482,6 +2485,7 @@ push: # trusted_private_chat: null # public_chat: null + # Uncomment to allow non-server-admin users to create groups on this server # #enable_group_creation: true diff --git a/synapse/config/room.py b/synapse/config/room.py index 77221208cecb..253a0ba583ac 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -110,20 +110,20 @@ def generate_config_section(self, **kwargs: Any) -> str: # is applied before that parameter. # #default_power_level_content_override: - # private_chat: { - # "events": { - # "com.example.myeventtype" : 0, - # "m.room.avatar": 50, - # "m.room.canonical_alias": 50, - # "m.room.encryption": 100, - # "m.room.history_visibility": 100, - # "m.room.name": 50, - # "m.room.power_levels": 100, - # "m.room.server_acl": 100, - # "m.room.tombstone": 100 - # }, - # "events_default": 1 - # } - # trusted_private_chat: null - # public_chat: null + # private_chat: { + # "events": { + # "com.example.myeventtype" : 0, + # "m.room.avatar": 50, + # "m.room.canonical_alias": 50, + # "m.room.encryption": 100, + # "m.room.history_visibility": 100, + # "m.room.name": 50, + # "m.room.power_levels": 100, + # "m.room.server_acl": 100, + # "m.room.tombstone": 100 + # }, + # "events_default": 1 + # } + # trusted_private_chat: null + # public_chat: null """ From 52197b01716e34210cf62af6884fc637e0c46a75 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 13:01:09 +0100 Subject: [PATCH 19/34] Fix case of create in default power level tests Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> --- tests/rest/client/test_rooms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index 240a2e68cddd..5df9287f5fc9 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -1246,7 +1246,7 @@ def test_power_levels_with_server_override(self) -> None: def test_power_levels_with_server_and_room_overrides(self) -> None: """ With a server configured to modify the room-level defaults, - Create a room, providing different overrides. + create a room, providing different overrides. Confirm that the room's power levels reflect both overrides, and choose the room overrides where they clash. """ From 55e1eccdd441cb06e4e87d6f02fd93550a1a32f1 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 13:03:21 +0100 Subject: [PATCH 20/34] Spread out multi-line docstring --- tests/rest/client/test_rooms.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index 5df9287f5fc9..79fa12bac9d9 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -1278,8 +1278,10 @@ def test_power_levels_with_server_and_room_overrides(self) -> None: class RoomPowerLevelOverridesInPracticeTestCase(RoomBase): - """Tests that we can really do various otherwise-prohibited actions - based on overriding the power levels in config.""" + """ + Tests that we can really do various otherwise-prohibited actions + based on overriding the power levels in config. + """ user_id = "@sid1:red" From 21459d86e9fd0a14c84e48f1e46c8bf59266da78 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 13:04:38 +0100 Subject: [PATCH 21/34] Use Python native string literal concatenation Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> --- tests/rest/client/test_rooms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index 79fa12bac9d9..914b2284376b 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -1313,7 +1313,7 @@ def test_normal_user_can_not_post_state_event(self) -> None: self.assertEqual(403, channel.code, msg=channel.result["body"]) self.assertEqual( "You don't have permission to post that to the room. " - + "user_level (0) < send_level (50)", + "user_level (0) < send_level (50)", channel.json_body["error"], ) From 08b00e1b87e13882d2268854c7c9f9f32e5df0be Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 13:09:41 +0100 Subject: [PATCH 22/34] Reduce the user of Cucumber-style Given/And comments to be more readable --- tests/rest/client/test_rooms.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index 914b2284376b..b7ad1f204547 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -1325,8 +1325,8 @@ def test_normal_user_can_not_post_state_event(self) -> None: }, ) def test_with_config_override_normal_user_can_post_state_event(self) -> None: - # Given the server has config allowing normal users to post my event type - # And I am a normal member of a room + # Given the server has config allowing normal users to post my event type, + # and I am a normal member of a room room_id = self.helper.create_room_as("@some_other_guy:red") self.helper.join(room=room_id, user=self.user_id) @@ -1375,9 +1375,9 @@ def test_any_room_override_defeats_config_override(self) -> None: }, ) def test_specific_room_override_defeats_config_override(self) -> None: - # Given the server has config allowing normal users to post my event type - # And I am a normal member of a room - # But the room was created with special permissions for this event type + # Given the server has config allowing normal users to post my event type, + # and I am a normal member of a room, + # but the room was created with special permissions for this event type extra_content = { "power_level_content_override": {"events": {"custom.event": 1}}, } @@ -1410,8 +1410,8 @@ def test_specific_room_override_defeats_config_override(self) -> None: }, ) def test_config_override_applies_only_to_specific_preset(self) -> None: - # Given the server has config for public_chats - # And I am a normal member of a private_chat room + # Given the server has config for public_chats, + # and I am a normal member of a private_chat room room_id = self.helper.create_room_as("@some_other_guy:red", is_public=False) self.helper.invite(room=room_id, src="@some_other_guy:red", targ=self.user_id) self.helper.join(room=room_id, user=self.user_id) From 9adeaa7d76d2fe0b8a3c92f0c34a226b7bdec9d1 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 13:17:32 +0100 Subject: [PATCH 23/34] Document allowed keys inside default_power_level_content_override --- synapse/config/room.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/synapse/config/room.py b/synapse/config/room.py index 253a0ba583ac..810f8f08c953 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -109,6 +109,14 @@ def generate_config_section(self, **kwargs: Any) -> str: # `power_level_content_override` parameter in the /createRoom API, but # is applied before that parameter. # + # Valid keys are some or all of `private_chat`, `trusted_private_chat` + # and `public_chat`. Inside each of those should be any of the + # properties allowed in `power_level_content_override` in the + # /createRoom API. If any property is missing, its default value will + # continue to be use. If any property is present, it will overwrite + # the existing default completely (so if the `events` property exists, + # the default event power levels will be ignored). + # #default_power_level_content_override: # private_chat: { # "events": { From 4dda230e405ad692f8178066afceda257d6f4759 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 13:28:46 +0100 Subject: [PATCH 24/34] Move default_power_level_content_override into a member --- synapse/handlers/room.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index ceb8d44bd495..8729ab1d7501 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -149,6 +149,10 @@ def __init__(self, hs: "HomeServer"): ) preset_config["encrypted"] = encrypted + self._default_power_level_content_override = ( + self.config.room.default_power_level_content_override + ) + self._replication = hs.get_replication_data_handler() # linearizer to stop two upgrades happening at once @@ -1046,15 +1050,12 @@ async def send(etype: str, content: JsonDict, **kwargs: Any) -> int: # If the server config contains default_power_level_content_override, # and that contains information for this room preset, apply it. - default_power_level_content_override = ( - self.config.room.default_power_level_content_override - ) if ( - default_power_level_content_override - and default_power_level_content_override.get(preset_config) + self._default_power_level_content_override + and self._default_power_level_content_override.get(preset_config) ): power_level_content.update( - default_power_level_content_override.get(preset_config) + self._default_power_level_content_override.get(preset_config) ) # Finally, if the user supplied specific permissions for this room, From ae9421caa38cf12e9b7dd7930cebffc87f6021c1 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 13:38:06 +0100 Subject: [PATCH 25/34] Remove assumptions about default power levels from tests --- tests/rest/client/test_rooms.py | 80 +++++---------------------------- 1 file changed, 10 insertions(+), 70 deletions(-) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index b7ad1f204547..8274eb42d7d0 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -1136,33 +1136,6 @@ def power_levels(self, room_id: str) -> Dict[str, Any]: room_id, "m.room.power_levels", self.admin_access_token ) - def test_default_power_levels_without_override(self) -> None: - room_id = self.helper.create_room_as(self.user_id) - self.assertEqual( - { - "ban": 50, - "events": { - "m.room.avatar": 50, - "m.room.canonical_alias": 50, - "m.room.encryption": 100, - "m.room.history_visibility": 100, - "m.room.name": 50, - "m.room.power_levels": 100, - "m.room.server_acl": 100, - "m.room.tombstone": 100, - }, - "events_default": 0, - "historical": 100, - "invite": 50, - "kick": 50, - "redact": 50, - "state_default": 50, - "users": {"@sid1:red": 100}, - "users_default": 0, - }, - self.power_levels(room_id), - ) - def test_default_power_levels_with_room_override(self) -> None: """ Create a room, providing power level overrides. @@ -1180,21 +1153,8 @@ def test_default_power_levels_with_room_override(self) -> None: }, ) self.assertEqual( - { - "ban": 50, - "events": { - "custom.event": 0, - }, - "events_default": 0, - "historical": 100, - "invite": 50, - "kick": 50, - "redact": 50, - "state_default": 50, - "users": {"@sid1:red": 100}, - "users_default": 0, - }, - self.power_levels(room_id), + { "custom.event": 0, }, + self.power_levels(room_id)["events"], ) @unittest.override_config( @@ -1217,20 +1177,9 @@ def test_power_levels_with_server_override(self) -> None: room_id = self.helper.create_room_as(self.user_id) self.assertEqual( { - "ban": 50, - "events": { - "custom.event": 0, - }, - "events_default": 0, - "historical": 100, - "invite": 50, - "kick": 50, - "redact": 50, - "state_default": 50, - "users": {"@sid1:red": 100}, - "users_default": 0, + "custom.event": 0, }, - self.power_levels(room_id), + self.power_levels(room_id)["events"], ) @unittest.override_config( @@ -1258,24 +1207,15 @@ def test_power_levels_with_server_and_room_overrides(self) -> None: }, ) + # Room override wins over server config self.assertEqual( - { - "ban": 13, # From server config override - "events": { - "room.event": 0, # From room override - }, - "events_default": 0, - "historical": 100, - "invite": 50, - "kick": 50, - "redact": 50, - "state_default": 50, - "users": {"@sid1:red": 100}, - "users_default": 0, - }, - self.power_levels(room_id), + {"room.event": 0}, + self.power_levels(room_id)["events"], ) + # But where there is no room override, server config wins + self.assertEqual(13, self.power_levels(room_id)["ban"]) + class RoomPowerLevelOverridesInPracticeTestCase(RoomBase): """ From aa43bb1bc76ff939f0011f9e8ba6f56861134035 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 13:39:35 +0100 Subject: [PATCH 26/34] Generate sample config --- docs/sample_config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index 71f9a725ebe2..416d51621682 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -2467,6 +2467,14 @@ push: # `power_level_content_override` parameter in the /createRoom API, but # is applied before that parameter. # +# Valid keys are some or all of `private_chat`, `trusted_private_chat` +# and `public_chat`. Inside each of those should be any of the +# properties allowed in `power_level_content_override` in the +# /createRoom API. If any property is missing, its default value will +# continue to be use. If any property is present, it will overwrite +# the existing default completely (so if the `events` property exists, +# the default event power levels will be ignored). +# #default_power_level_content_override: # private_chat: { # "events": { From d84ba9a2876706a79af362d34d3b1316b106bfd7 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 10 May 2022 13:46:51 +0100 Subject: [PATCH 27/34] Code formatting --- tests/rest/client/test_rooms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index 8274eb42d7d0..ad416e2fd8c0 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -1153,7 +1153,9 @@ def test_default_power_levels_with_room_override(self) -> None: }, ) self.assertEqual( - { "custom.event": 0, }, + { + "custom.event": 0, + }, self.power_levels(room_id)["events"], ) From 990b7fa77d6cdd4582470697b1d7eea0d823293c Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 12 May 2022 09:23:03 +0100 Subject: [PATCH 28/34] Tidy default override if, and check against None instead of falsey --- synapse/handlers/room.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 8729ab1d7501..8b31789aebeb 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -1050,13 +1050,10 @@ async def send(etype: str, content: JsonDict, **kwargs: Any) -> int: # If the server config contains default_power_level_content_override, # and that contains information for this room preset, apply it. - if ( - self._default_power_level_content_override - and self._default_power_level_content_override.get(preset_config) - ): - power_level_content.update( - self._default_power_level_content_override.get(preset_config) - ) + if self._default_power_level_content_override: + override = self._default_power_level_content_override.get(preset_config) + if override is not None: + power_level_content.update(override) # Finally, if the user supplied specific permissions for this room, # apply those. From 8122c1b418f3254e753058161670a3d3c654b7a7 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 12 May 2022 09:24:30 +0100 Subject: [PATCH 29/34] Fix typo use->used Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> --- synapse/config/room.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/config/room.py b/synapse/config/room.py index 810f8f08c953..8ad54b027da3 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -113,7 +113,7 @@ def generate_config_section(self, **kwargs: Any) -> str: # and `public_chat`. Inside each of those should be any of the # properties allowed in `power_level_content_override` in the # /createRoom API. If any property is missing, its default value will - # continue to be use. If any property is present, it will overwrite + # continue to be used. If any property is present, it will overwrite # the existing default completely (so if the `events` property exists, # the default event power levels will be ignored). # From a91a04326ac6312b13a7eec6e9aa40dd15cefec3 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 12 May 2022 09:26:11 +0100 Subject: [PATCH 30/34] Remove extraneous null presets in example config --- docs/sample_config.yaml | 2 -- synapse/config/room.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index 416d51621682..2e7139548e9e 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -2490,8 +2490,6 @@ push: # }, # "events_default": 1 # } -# trusted_private_chat: null -# public_chat: null # Uncomment to allow non-server-admin users to create groups on this server diff --git a/synapse/config/room.py b/synapse/config/room.py index 8ad54b027da3..1747fc4d72f2 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -132,6 +132,4 @@ def generate_config_section(self, **kwargs: Any) -> str: # }, # "events_default": 1 # } - # trusted_private_chat: null - # public_chat: null """ From 383e0213397660a6d99d34daf9c55de399cb2b36 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 12 May 2022 09:28:53 +0100 Subject: [PATCH 31/34] Regenerate sample config --- docs/sample_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index 2e7139548e9e..c176f542ef23 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -2471,7 +2471,7 @@ push: # and `public_chat`. Inside each of those should be any of the # properties allowed in `power_level_content_override` in the # /createRoom API. If any property is missing, its default value will -# continue to be use. If any property is present, it will overwrite +# continue to be used. If any property is present, it will overwrite # the existing default completely (so if the `events` property exists, # the default event power levels will be ignored). # From b2ae9c9cf4cee9b986cf51d95a82137112075bfb Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 12 May 2022 11:14:15 +0100 Subject: [PATCH 32/34] Add wording "per room preset" Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> --- changelog.d/12618.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/12618.feature b/changelog.d/12618.feature index 71639f9e1cbd..37fa03b3cb41 100644 --- a/changelog.d/12618.feature +++ b/changelog.d/12618.feature @@ -1 +1 @@ -Add a `default_power_level_content_override` config option to set default room power levels. +Add a `default_power_level_content_override` config option to set default room power levels per room preset. From e1a913d4d0e94e5824fe40c1772572dee48312a3 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 12 May 2022 11:14:34 +0100 Subject: [PATCH 33/34] Quotes for config key example Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> --- synapse/config/room.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/config/room.py b/synapse/config/room.py index 1747fc4d72f2..47ecab14eaf3 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -118,7 +118,7 @@ def generate_config_section(self, **kwargs: Any) -> str: # the default event power levels will be ignored). # #default_power_level_content_override: - # private_chat: { + # "private_chat": { # "events": { # "com.example.myeventtype" : 0, # "m.room.avatar": 50, From 8a639df701e63a616ebab74f98bd090206c3c48d Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 12 May 2022 11:16:55 +0100 Subject: [PATCH 34/34] Make config example valid yaml --- docs/sample_config.yaml | 22 ++++++++++------------ synapse/config/room.py | 22 ++++++++++------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index c176f542ef23..e42b968cef2d 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -2476,20 +2476,18 @@ push: # the default event power levels will be ignored). # #default_power_level_content_override: -# private_chat: { -# "events": { -# "com.example.myeventtype" : 0, -# "m.room.avatar": 50, -# "m.room.canonical_alias": 50, -# "m.room.encryption": 100, -# "m.room.history_visibility": 100, -# "m.room.name": 50, -# "m.room.power_levels": 100, -# "m.room.server_acl": 100, +# private_chat: +# "events": +# "com.example.myeventtype" : 0 +# "m.room.avatar": 50 +# "m.room.canonical_alias": 50 +# "m.room.encryption": 100 +# "m.room.history_visibility": 100 +# "m.room.name": 50 +# "m.room.power_levels": 100 +# "m.room.server_acl": 100 # "m.room.tombstone": 100 -# }, # "events_default": 1 -# } # Uncomment to allow non-server-admin users to create groups on this server diff --git a/synapse/config/room.py b/synapse/config/room.py index 47ecab14eaf3..462d85ac1d1e 100644 --- a/synapse/config/room.py +++ b/synapse/config/room.py @@ -118,18 +118,16 @@ def generate_config_section(self, **kwargs: Any) -> str: # the default event power levels will be ignored). # #default_power_level_content_override: - # "private_chat": { - # "events": { - # "com.example.myeventtype" : 0, - # "m.room.avatar": 50, - # "m.room.canonical_alias": 50, - # "m.room.encryption": 100, - # "m.room.history_visibility": 100, - # "m.room.name": 50, - # "m.room.power_levels": 100, - # "m.room.server_acl": 100, + # private_chat: + # "events": + # "com.example.myeventtype" : 0 + # "m.room.avatar": 50 + # "m.room.canonical_alias": 50 + # "m.room.encryption": 100 + # "m.room.history_visibility": 100 + # "m.room.name": 50 + # "m.room.power_levels": 100 + # "m.room.server_acl": 100 # "m.room.tombstone": 100 - # }, # "events_default": 1 - # } """