From 99a7e7e0230cba5d00ec204926edae89d4b6b8c3 Mon Sep 17 00:00:00 2001
From: Nicolas Werner <89468146+nico-famedly@users.noreply.github.com>
Date: Thu, 29 Sep 2022 10:57:00 +0000
Subject: [PATCH] Always send default and rule_id to clients (#13904)

---
 changelog.d/13904.bugfix     | 1 +
 synapse/push/clientformat.py | 6 ++----
 2 files changed, 3 insertions(+), 4 deletions(-)
 create mode 100644 changelog.d/13904.bugfix

diff --git a/changelog.d/13904.bugfix b/changelog.d/13904.bugfix
new file mode 100644
index 0000000000..397a3108ac
--- /dev/null
+++ b/changelog.d/13904.bugfix
@@ -0,0 +1 @@
+Fix a bug introduced in 1.66 where some required fields in the pushrules sent to clients were not present anymore. Contributed by Nico.
diff --git a/synapse/push/clientformat.py b/synapse/push/clientformat.py
index ebc13beda1..7095ae83f9 100644
--- a/synapse/push/clientformat.py
+++ b/synapse/push/clientformat.py
@@ -102,10 +102,8 @@ def _rule_to_template(rule: PushRule) -> Optional[Dict[str, Any]]:
         # with PRIORITY_CLASS_INVERSE_MAP.
         raise ValueError("Unexpected template_name: %s" % (template_name,))
 
-    if unscoped_rule_id:
-        templaterule["rule_id"] = unscoped_rule_id
-    if rule.default:
-        templaterule["default"] = True
+    templaterule["rule_id"] = unscoped_rule_id
+    templaterule["default"] = rule.default
     return templaterule