Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize support for MSC4010: push rules & account data. #17022

Merged
merged 4 commits into from
Apr 9, 2024
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/17022.feature
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 0 additions & 5 deletions synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,6 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
# Check that none of the other config options conflict with MSC3861 when enabled
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(
"msc4028_push_encrypted_events", False
)
Expand Down
29 changes: 6 additions & 23 deletions synapse/rest/client/account_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ async def on_PUT(
raise AuthError(403, "Cannot add account data for other users.")

# 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)

Expand All @@ -108,10 +107,7 @@ async def on_GET(
raise AuthError(403, "Cannot get account data for other users.")

# Push rules are stored in a separate table and must be queried separately.
if (
self._hs.config.experimental.msc4010_push_rules_account_data
and account_data_type == AccountDataTypes.PUSH_RULES
):
if account_data_type == AccountDataTypes.PUSH_RULES:
account_data: Optional[JsonMapping] = (
await self._push_rules_handler.push_rules_for_user(requester.user)
)
Expand Down Expand Up @@ -162,8 +158,7 @@ async def on_DELETE(
raise AuthError(403, "Cannot delete account data for other users.")

# 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)

Expand Down Expand Up @@ -209,15 +204,7 @@ async def on_PUT(
)

# 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)
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,
)
_check_can_set_account_data_type(account_data_type)

body = parse_json_object_from_request(request)

Expand Down Expand Up @@ -256,10 +243,7 @@ async def on_GET(
)

# Room-specific push rules are not currently supported.
if (
self._hs.config.experimental.msc4010_push_rules_account_data
and account_data_type == AccountDataTypes.PUSH_RULES
):
if account_data_type == AccountDataTypes.PUSH_RULES:
account_data: Optional[JsonMapping] = {}
else:
account_data = await self.store.get_account_data_for_room_and_type(
Expand Down Expand Up @@ -317,8 +301,7 @@ async def on_DELETE(
)

# 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(
user_id, room_id, account_data_type
Expand Down
Loading