Fix a typo in MSC3873 config option. (#15138)

Previously the experimental configuration option referred to the wrong
MSC number.
pull/15152/head
Patrick Cloke 2023-02-23 16:06:42 -05:00 committed by GitHub
parent 1a1738eca2
commit ec79870f14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

1
changelog.d/15138.misc Normal file
View File

@ -0,0 +1 @@
Fix a typo in an experimental config setting.

View File

@ -175,8 +175,8 @@ class ExperimentalConfig(Config):
) )
# MSC3873: Disambiguate event_match keys. # MSC3873: Disambiguate event_match keys.
self.msc3783_escape_event_match_key = experimental.get( self.msc3873_escape_event_match_key = experimental.get(
"msc3783_escape_event_match_key", False "msc3873_escape_event_match_key", False
) )
# MSC3952: Intentional mentions, this depends on MSC3758. # MSC3952: Intentional mentions, this depends on MSC3758.

View File

@ -276,7 +276,7 @@ class BulkPushRuleEvaluator:
if related_event is not None: if related_event is not None:
related_events[relation_type] = _flatten_dict( related_events[relation_type] = _flatten_dict(
related_event, 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 = ( reply_event_id = (
@ -294,7 +294,7 @@ class BulkPushRuleEvaluator:
if related_event is not None: if related_event is not None:
related_events["m.in_reply_to"] = _flatten_dict( related_events["m.in_reply_to"] = _flatten_dict(
related_event, 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. # indicate that this is from a fallback relation.
@ -412,7 +412,7 @@ class BulkPushRuleEvaluator:
evaluator = PushRuleEvaluator( evaluator = PushRuleEvaluator(
_flatten_dict( _flatten_dict(
event, 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, has_mentions,
user_mentions, user_mentions,
@ -507,7 +507,7 @@ def _flatten_dict(
prefix: Optional[List[str]] = None, prefix: Optional[List[str]] = None,
result: Optional[Dict[str, JsonValue]] = None, result: Optional[Dict[str, JsonValue]] = None,
*, *,
msc3783_escape_event_match_key: bool = False, msc3873_escape_event_match_key: bool = False,
) -> Dict[str, JsonValue]: ) -> Dict[str, JsonValue]:
""" """
Given a JSON dictionary (or event) which might contain sub dictionaries, Given a JSON dictionary (or event) which might contain sub dictionaries,
@ -536,7 +536,7 @@ def _flatten_dict(
if result is None: if result is None:
result = {} result = {}
for key, value in d.items(): 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 # 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 # extra backslash). This is since a period is used as a separator between
# nested fields. # nested fields.
@ -552,7 +552,7 @@ def _flatten_dict(
value, value,
prefix=(prefix + [key]), prefix=(prefix + [key]),
result=result, 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 # `room_version` should only ever be set when looking at the top level of an event

View File

@ -54,7 +54,7 @@ class FlattenDictTestCase(unittest.TestCase):
self.assertEqual({"m.foo.b\\ar": "abc"}, _flatten_dict(input)) self.assertEqual({"m.foo.b\\ar": "abc"}, _flatten_dict(input))
self.assertEqual( self.assertEqual(
{"m\\.foo.b\\\\ar": "abc"}, {"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: def test_non_string(self) -> None: