diff options
author | Erik Johnston <erik@matrix.org> | 2016-01-19 11:27:27 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-01-19 11:27:27 +0000 |
commit | 47e7963e50704a1a981b8c009f8403085be721a6 (patch) | |
tree | 1a8b4930d67c314c21d40e8e48436a0b246476f1 /synapse/rest | |
parent | Merge pull request #503 from matrix-org/daniel/nonghosts (diff) | |
parent | Take a deepcopy of push rules before mutating them (diff) | |
download | synapse-47e7963e50704a1a981b8c009f8403085be721a6.tar.xz |
Merge pull request #502 from matrix-org/erikj/push_notif_perf
Unread notification performance.
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/client/v1/push_rule.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/synapse/rest/client/v1/push_rule.py b/synapse/rest/client/v1/push_rule.py index 0cbd9fe08a..2272d66dc7 100644 --- a/synapse/rest/client/v1/push_rule.py +++ b/synapse/rest/client/v1/push_rule.py @@ -27,6 +27,7 @@ from synapse.push.rulekinds import ( PRIORITY_CLASS_MAP, PRIORITY_CLASS_INVERSE_MAP ) +import copy import simplejson as json @@ -126,7 +127,8 @@ class PushRuleRestServlet(ClientV1RestServlet): rule["actions"] = json.loads(rawrule["actions"]) ruleslist.append(rule) - ruleslist = baserules.list_with_base_rules(ruleslist, user) + # We're going to be mutating this a lot, so do a deep copy + ruleslist = copy.deepcopy(baserules.list_with_base_rules(ruleslist)) rules = {'global': {}, 'device': {}} @@ -140,6 +142,16 @@ class PushRuleRestServlet(ClientV1RestServlet): template_name = _priority_class_to_template_name(r['priority_class']) + # Remove internal stuff. + for c in r["conditions"]: + c.pop("_id", None) + + pattern_type = c.pop("pattern_type", None) + if pattern_type == "user_id": + c["pattern"] = user.to_string() + elif pattern_type == "user_localpart": + c["pattern"] = user.localpart + if r['priority_class'] > PRIORITY_CLASS_MAP['override']: # per-device rule profile_tag = _profile_tag_from_conditions(r["conditions"]) |