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

Commit

Permalink
Fix a typo in MSC3873 config option. (#15138)
Browse files Browse the repository at this point in the history
Previously the experimental configuration option referred to the wrong
MSC number.
  • Loading branch information
clokep committed Feb 23, 2023
1 parent 1a1738e commit ec79870
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.d/15138.misc
@@ -0,0 +1 @@
Fix a typo in an experimental config setting.
4 changes: 2 additions & 2 deletions synapse/config/experimental.py
Expand Up @@ -175,8 +175,8 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
)

# MSC3873: Disambiguate event_match keys.
self.msc3783_escape_event_match_key = experimental.get(
"msc3783_escape_event_match_key", False
self.msc3873_escape_event_match_key = experimental.get(
"msc3873_escape_event_match_key", False
)

# MSC3952: Intentional mentions, this depends on MSC3758.
Expand Down
12 changes: 6 additions & 6 deletions synapse/push/bulk_push_rule_evaluator.py
Expand Up @@ -276,7 +276,7 @@ async def _related_events(
if related_event is not None:
related_events[relation_type] = _flatten_dict(
related_event,
msc3783_escape_event_match_key=self.hs.config.experimental.msc3783_escape_event_match_key,
msc3873_escape_event_match_key=self.hs.config.experimental.msc3873_escape_event_match_key,
)

reply_event_id = (
Expand All @@ -294,7 +294,7 @@ async def _related_events(
if related_event is not None:
related_events["m.in_reply_to"] = _flatten_dict(
related_event,
msc3783_escape_event_match_key=self.hs.config.experimental.msc3783_escape_event_match_key,
msc3873_escape_event_match_key=self.hs.config.experimental.msc3873_escape_event_match_key,
)

# indicate that this is from a fallback relation.
Expand Down Expand Up @@ -412,7 +412,7 @@ async def _action_for_event_by_user(
evaluator = PushRuleEvaluator(
_flatten_dict(
event,
msc3783_escape_event_match_key=self.hs.config.experimental.msc3783_escape_event_match_key,
msc3873_escape_event_match_key=self.hs.config.experimental.msc3873_escape_event_match_key,
),
has_mentions,
user_mentions,
Expand Down Expand Up @@ -507,7 +507,7 @@ def _flatten_dict(
prefix: Optional[List[str]] = None,
result: Optional[Dict[str, JsonValue]] = None,
*,
msc3783_escape_event_match_key: bool = False,
msc3873_escape_event_match_key: bool = False,
) -> Dict[str, JsonValue]:
"""
Given a JSON dictionary (or event) which might contain sub dictionaries,
Expand Down Expand Up @@ -536,7 +536,7 @@ def _flatten_dict(
if result is None:
result = {}
for key, value in d.items():
if msc3783_escape_event_match_key:
if msc3873_escape_event_match_key:
# Escape periods in the key with a backslash (and backslashes with an
# extra backslash). This is since a period is used as a separator between
# nested fields.
Expand All @@ -552,7 +552,7 @@ def _flatten_dict(
value,
prefix=(prefix + [key]),
result=result,
msc3783_escape_event_match_key=msc3783_escape_event_match_key,
msc3873_escape_event_match_key=msc3873_escape_event_match_key,
)

# `room_version` should only ever be set when looking at the top level of an event
Expand Down
2 changes: 1 addition & 1 deletion tests/push/test_push_rule_evaluator.py
Expand Up @@ -54,7 +54,7 @@ def test_nested(self) -> None:
self.assertEqual({"m.foo.b\\ar": "abc"}, _flatten_dict(input))
self.assertEqual(
{"m\\.foo.b\\\\ar": "abc"},
_flatten_dict(input, msc3783_escape_event_match_key=True),
_flatten_dict(input, msc3873_escape_event_match_key=True),
)

def test_non_string(self) -> None:
Expand Down

0 comments on commit ec79870

Please sign in to comment.