mirror of
https://github.com/element-hq/synapse.git
synced 2025-03-31 03:45:13 +00:00
Stabilize support for MSC4010: push rules & account data. (#17022)
See [MSC4010](https://github.com/matrix-org/matrix-spec-proposals/pull/4010), but this is pretty much just removing an experimental flag. Part of #17021
This commit is contained in:
parent
a2a543fd12
commit
657b8cc75c
3 changed files with 7 additions and 28 deletions
1
changelog.d/17022.feature
Normal file
1
changelog.d/17022.feature
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Stabilize support for [MSC4010](https://github.com/matrix-org/matrix-spec-proposals/pull/4010) which clarifies the interaction of push rules and account data. Contributed by @clokep.
|
|
@ -404,11 +404,6 @@ class ExperimentalConfig(Config):
|
||||||
# Check that none of the other config options conflict with MSC3861 when enabled
|
# Check that none of the other config options conflict with MSC3861 when enabled
|
||||||
self.msc3861.check_config_conflicts(self.root)
|
self.msc3861.check_config_conflicts(self.root)
|
||||||
|
|
||||||
# MSC4010: Do not allow setting m.push_rules account data.
|
|
||||||
self.msc4010_push_rules_account_data = experimental.get(
|
|
||||||
"msc4010_push_rules_account_data", False
|
|
||||||
)
|
|
||||||
|
|
||||||
self.msc4028_push_encrypted_events = experimental.get(
|
self.msc4028_push_encrypted_events = experimental.get(
|
||||||
"msc4028_push_encrypted_events", False
|
"msc4028_push_encrypted_events", False
|
||||||
)
|
)
|
||||||
|
|
|
@ -81,8 +81,7 @@ class AccountDataServlet(RestServlet):
|
||||||
raise AuthError(403, "Cannot add account data for other users.")
|
raise AuthError(403, "Cannot add account data for other users.")
|
||||||
|
|
||||||
# Raise an error if the account data type cannot be set directly.
|
# Raise an error if the account data type cannot be set directly.
|
||||||
if self._hs.config.experimental.msc4010_push_rules_account_data:
|
_check_can_set_account_data_type(account_data_type)
|
||||||
_check_can_set_account_data_type(account_data_type)
|
|
||||||
|
|
||||||
body = parse_json_object_from_request(request)
|
body = parse_json_object_from_request(request)
|
||||||
|
|
||||||
|
@ -108,10 +107,7 @@ class AccountDataServlet(RestServlet):
|
||||||
raise AuthError(403, "Cannot get account data for other users.")
|
raise AuthError(403, "Cannot get account data for other users.")
|
||||||
|
|
||||||
# Push rules are stored in a separate table and must be queried separately.
|
# Push rules are stored in a separate table and must be queried separately.
|
||||||
if (
|
if account_data_type == AccountDataTypes.PUSH_RULES:
|
||||||
self._hs.config.experimental.msc4010_push_rules_account_data
|
|
||||||
and account_data_type == AccountDataTypes.PUSH_RULES
|
|
||||||
):
|
|
||||||
account_data: Optional[JsonMapping] = (
|
account_data: Optional[JsonMapping] = (
|
||||||
await self._push_rules_handler.push_rules_for_user(requester.user)
|
await self._push_rules_handler.push_rules_for_user(requester.user)
|
||||||
)
|
)
|
||||||
|
@ -162,8 +158,7 @@ class UnstableAccountDataServlet(RestServlet):
|
||||||
raise AuthError(403, "Cannot delete account data for other users.")
|
raise AuthError(403, "Cannot delete account data for other users.")
|
||||||
|
|
||||||
# Raise an error if the account data type cannot be set directly.
|
# Raise an error if the account data type cannot be set directly.
|
||||||
if self._hs.config.experimental.msc4010_push_rules_account_data:
|
_check_can_set_account_data_type(account_data_type)
|
||||||
_check_can_set_account_data_type(account_data_type)
|
|
||||||
|
|
||||||
await self.handler.remove_account_data_for_user(user_id, account_data_type)
|
await self.handler.remove_account_data_for_user(user_id, account_data_type)
|
||||||
|
|
||||||
|
@ -209,15 +204,7 @@ class RoomAccountDataServlet(RestServlet):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Raise an error if the account data type cannot be set directly.
|
# Raise an error if the account data type cannot be set directly.
|
||||||
if self._hs.config.experimental.msc4010_push_rules_account_data:
|
_check_can_set_account_data_type(account_data_type)
|
||||||
_check_can_set_account_data_type(account_data_type)
|
|
||||||
elif account_data_type == ReceiptTypes.FULLY_READ:
|
|
||||||
raise SynapseError(
|
|
||||||
405,
|
|
||||||
"Cannot set m.fully_read through this API."
|
|
||||||
" Use /rooms/!roomId:server.name/read_markers",
|
|
||||||
Codes.BAD_JSON,
|
|
||||||
)
|
|
||||||
|
|
||||||
body = parse_json_object_from_request(request)
|
body = parse_json_object_from_request(request)
|
||||||
|
|
||||||
|
@ -256,10 +243,7 @@ class RoomAccountDataServlet(RestServlet):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Room-specific push rules are not currently supported.
|
# Room-specific push rules are not currently supported.
|
||||||
if (
|
if account_data_type == AccountDataTypes.PUSH_RULES:
|
||||||
self._hs.config.experimental.msc4010_push_rules_account_data
|
|
||||||
and account_data_type == AccountDataTypes.PUSH_RULES
|
|
||||||
):
|
|
||||||
account_data: Optional[JsonMapping] = {}
|
account_data: Optional[JsonMapping] = {}
|
||||||
else:
|
else:
|
||||||
account_data = await self.store.get_account_data_for_room_and_type(
|
account_data = await self.store.get_account_data_for_room_and_type(
|
||||||
|
@ -317,8 +301,7 @@ class UnstableRoomAccountDataServlet(RestServlet):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Raise an error if the account data type cannot be set directly.
|
# Raise an error if the account data type cannot be set directly.
|
||||||
if self._hs.config.experimental.msc4010_push_rules_account_data:
|
_check_can_set_account_data_type(account_data_type)
|
||||||
_check_can_set_account_data_type(account_data_type)
|
|
||||||
|
|
||||||
await self.handler.remove_account_data_for_room(
|
await self.handler.remove_account_data_for_room(
|
||||||
user_id, room_id, account_data_type
|
user_id, room_id, account_data_type
|
||||||
|
|
Loading…
Add table
Reference in a new issue