Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

push rules: fix internal conversion from _type to value #15781

Merged
merged 7 commits into from
Jun 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions synapse/push/clientformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ def format_push_rules_for_user(

rulearray.append(template_rule)

for type_key in ("pattern", "value"):
MatMaul marked this conversation as resolved.
Show resolved Hide resolved
type_value = template_rule.pop(f"{type_key}_type", None)
if type_value == "user_id":
template_rule[type_key] = user.to_string()
elif type_value == "user_localpart":
template_rule[type_key] = user.localpart

template_rule["enabled"] = enabled

if "conditions" not in template_rule:
Expand All @@ -63,15 +56,12 @@ def format_push_rules_for_user(
for c in template_rule["conditions"]:
c.pop("_cache_key", 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

sender_type = c.pop("sender_type", None)
if sender_type == "user_id":
c["sender"] = user.to_string()
for type_key in ("pattern", "sender", "value"):
MatMaul marked this conversation as resolved.
Show resolved Hide resolved
type_value = c.pop(f"{type_key}_type", None)
if type_value == "user_id":
c[type_key] = user.to_string()
elif type_value == "user_localpart":
c[type_key] = user.localpart

return rules

Expand Down