From f7d2ad2cebadd129da4f0f46d43a991f7cdfe24b Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Wed, 2 Nov 2022 20:56:48 +0100 Subject: [PATCH 1/2] Send content rules with pattern_type to clients Dirty fix for #14348 A proper fix would have proper tests and factor out the pattern_type cases as well as clean up the logic. Signed-off-by: Nicolas Werner --- synapse/push/clientformat.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/synapse/push/clientformat.py b/synapse/push/clientformat.py index 7095ae83f931..622a1e35c5fe 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. From ab1d7c79c5b1b70835833e97f1d5df2ee6a452d3 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Wed, 2 Nov 2022 21:15:22 +0100 Subject: [PATCH 2/2] Add changelog Signed-off-by: Nicolas Werner --- changelog.d/14356.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/14356.bugfix diff --git a/changelog.d/14356.bugfix b/changelog.d/14356.bugfix new file mode 100644 index 000000000000..288d58a5400b --- /dev/null +++ b/changelog.d/14356.bugfix @@ -0,0 +1 @@ +Fix a bug introduced in 1.66 which would not send certain pushrules to clients. Contributed by Nico.