diff options
author | DeepBlueV7.X <nicolas.werner@hotmail.de> | 2022-11-15 16:29:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-15 15:29:30 +0000 |
commit | 63cc56affa3872443fffcac655413a8d9ffabfe4 (patch) | |
tree | 17f52588b868f5ab422f71f14201960f01692574 /synapse | |
parent | Support using SSL on worker endpoints. (#14128) (diff) | |
download | synapse-63cc56affa3872443fffcac655413a8d9ffabfe4.tar.xz |
Send content rules with pattern_type to clients (#14356)
Diffstat (limited to '')
-rw-r--r-- | synapse/push/clientformat.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/synapse/push/clientformat.py b/synapse/push/clientformat.py index 7095ae83f9..622a1e35c5 100644 --- a/synapse/push/clientformat.py +++ b/synapse/push/clientformat.py @@ -44,6 +44,12 @@ def format_push_rules_for_user( rulearray.append(template_rule) + pattern_type = template_rule.pop("pattern_type", None) + if pattern_type == "user_id": + template_rule["pattern"] = user.to_string() + elif pattern_type == "user_localpart": + template_rule["pattern"] = user.localpart + template_rule["enabled"] = enabled if "conditions" not in template_rule: @@ -93,10 +99,14 @@ def _rule_to_template(rule: PushRule) -> Optional[Dict[str, Any]]: if len(rule.conditions) != 1: return None thecond = rule.conditions[0] - if "pattern" not in thecond: - return None + templaterule = {"actions": rule.actions} - templaterule["pattern"] = thecond["pattern"] + if "pattern" in thecond: + templaterule["pattern"] = thecond["pattern"] + elif "pattern_type" in thecond: + templaterule["pattern_type"] = thecond["pattern_type"] + else: + return None else: # This should not be reached unless this function is not kept in sync # with PRIORITY_CLASS_INVERSE_MAP. |