diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2020-08-10 11:48:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-10 11:48:01 +0100 |
commit | cdbb8e6d6e36e0b6bc36e676d8fe66c96986b399 (patch) | |
tree | 107cf5525dc4dffda31be025ea138485aed68073 /synapse/rest/client/v1 | |
parent | Convert directory, e2e_room_keys, end_to_end_keys, monthly_active_users datab... (diff) | |
parent | Typo (diff) | |
download | synapse-cdbb8e6d6e36e0b6bc36e676d8fe66c96986b399.tar.xz |
Implement new experimental push rules (#7997)
With an undocumented configuration setting to enable them for specific users.
Diffstat (limited to 'synapse/rest/client/v1')
-rw-r--r-- | synapse/rest/client/v1/push_rule.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/rest/client/v1/push_rule.py b/synapse/rest/client/v1/push_rule.py index 9fd4908136..00831879f3 100644 --- a/synapse/rest/client/v1/push_rule.py +++ b/synapse/rest/client/v1/push_rule.py @@ -25,7 +25,7 @@ from synapse.http.servlet import ( parse_json_value_from_request, parse_string, ) -from synapse.push.baserules import BASE_RULE_IDS +from synapse.push.baserules import BASE_RULE_IDS, NEW_RULE_IDS from synapse.push.clientformat import format_push_rules_for_user from synapse.push.rulekinds import PRIORITY_CLASS_MAP from synapse.rest.client.v2_alpha._base import client_patterns @@ -45,6 +45,8 @@ class PushRuleRestServlet(RestServlet): self.notifier = hs.get_notifier() self._is_worker = hs.config.worker_app is not None + self._users_new_default_push_rules = hs.config.users_new_default_push_rules + async def on_PUT(self, request, path): if self._is_worker: raise Exception("Cannot handle PUT /push_rules on worker") @@ -179,7 +181,12 @@ class PushRuleRestServlet(RestServlet): rule_id = spec["rule_id"] is_default_rule = rule_id.startswith(".") if is_default_rule: - if namespaced_rule_id not in BASE_RULE_IDS: + if user_id in self._users_new_default_push_rules: + rule_ids = NEW_RULE_IDS + else: + rule_ids = BASE_RULE_IDS + + if namespaced_rule_id not in rule_ids: raise SynapseError(404, "Unknown rule %r" % (namespaced_rule_id,)) return self.store.set_push_rule_actions( user_id, namespaced_rule_id, actions, is_default_rule |