mirror of
https://mau.dev/maunium/synapse.git
synced 2024-09-02 07:55:28 +02:00
Fix PUT /pushrules to use the right rule IDs
This commit is contained in:
parent
1678057b56
commit
e2f1cccc8a
1 changed files with 9 additions and 2 deletions
|
@ -25,7 +25,7 @@ from synapse.http.servlet import (
|
||||||
parse_json_value_from_request,
|
parse_json_value_from_request,
|
||||||
parse_string,
|
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.clientformat import format_push_rules_for_user
|
||||||
from synapse.push.rulekinds import PRIORITY_CLASS_MAP
|
from synapse.push.rulekinds import PRIORITY_CLASS_MAP
|
||||||
from synapse.rest.client.v2_alpha._base import client_patterns
|
from synapse.rest.client.v2_alpha._base import client_patterns
|
||||||
|
@ -45,6 +45,8 @@ class PushRuleRestServlet(RestServlet):
|
||||||
self.notifier = hs.get_notifier()
|
self.notifier = hs.get_notifier()
|
||||||
self._is_worker = hs.config.worker_app is not None
|
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):
|
async def on_PUT(self, request, path):
|
||||||
if self._is_worker:
|
if self._is_worker:
|
||||||
raise Exception("Cannot handle PUT /push_rules on worker")
|
raise Exception("Cannot handle PUT /push_rules on worker")
|
||||||
|
@ -179,7 +181,12 @@ class PushRuleRestServlet(RestServlet):
|
||||||
rule_id = spec["rule_id"]
|
rule_id = spec["rule_id"]
|
||||||
is_default_rule = rule_id.startswith(".")
|
is_default_rule = rule_id.startswith(".")
|
||||||
if is_default_rule:
|
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,))
|
raise SynapseError(404, "Unknown rule %r" % (namespaced_rule_id,))
|
||||||
return self.store.set_push_rule_actions(
|
return self.store.set_push_rule_actions(
|
||||||
user_id, namespaced_rule_id, actions, is_default_rule
|
user_id, namespaced_rule_id, actions, is_default_rule
|
||||||
|
|
Loading…
Reference in a new issue