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

Commit 5a234ea

Browse files
committed
Use the stable identifier for MSC3966.
1 parent fd9cadc commit 5a234ea

File tree

9 files changed

+13
-55
lines changed

9 files changed

+13
-55
lines changed

changelog.d/15187.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stabilise support for [MSC3966](https://github.com/matrix-org/matrix-spec-proposals/pull/3966): `event_property_contains` push condition.

rust/benches/evaluator.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ fn bench_match_exact(b: &mut Bencher) {
5252
true,
5353
vec![],
5454
false,
55-
false,
5655
)
5756
.unwrap();
5857

@@ -98,7 +97,6 @@ fn bench_match_word(b: &mut Bencher) {
9897
true,
9998
vec![],
10099
false,
101-
false,
102100
)
103101
.unwrap();
104102

@@ -144,7 +142,6 @@ fn bench_match_word_miss(b: &mut Bencher) {
144142
true,
145143
vec![],
146144
false,
147-
false,
148145
)
149146
.unwrap();
150147

@@ -190,7 +187,6 @@ fn bench_eval_message(b: &mut Bencher) {
190187
true,
191188
vec![],
192189
false,
193-
false,
194190
)
195191
.unwrap();
196192

rust/src/push/evaluator.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ pub struct PushRuleEvaluator {
9696
/// If MSC3931 (room version feature flags) is enabled. Usually controlled by the same
9797
/// flag as MSC1767 (extensible events core).
9898
msc3931_enabled: bool,
99-
100-
/// If MSC3966 (exact_event_property_contains push rule condition) is enabled.
101-
msc3966_exact_event_property_contains: bool,
10299
}
103100

104101
#[pymethods]
@@ -116,7 +113,6 @@ impl PushRuleEvaluator {
116113
related_event_match_enabled: bool,
117114
room_version_feature_flags: Vec<String>,
118115
msc3931_enabled: bool,
119-
msc3966_exact_event_property_contains: bool,
120116
) -> Result<Self, Error> {
121117
let body = match flattened_keys.get("content.body") {
122118
Some(JsonValue::Value(SimpleJsonValue::Str(s))) => s.clone(),
@@ -134,7 +130,6 @@ impl PushRuleEvaluator {
134130
related_event_match_enabled,
135131
room_version_feature_flags,
136132
msc3931_enabled,
137-
msc3966_exact_event_property_contains,
138133
})
139134
}
140135

@@ -301,8 +296,8 @@ impl PushRuleEvaluator {
301296
Some(Cow::Borrowed(pattern)),
302297
)?
303298
}
304-
KnownCondition::ExactEventPropertyContains(event_property_is) => self
305-
.match_exact_event_property_contains(
299+
KnownCondition::EventPropertyContains(event_property_is) => self
300+
.match_event_property_contains(
306301
event_property_is.key.clone(),
307302
event_property_is.value.clone(),
308303
)?,
@@ -321,7 +316,7 @@ impl PushRuleEvaluator {
321316
EventMatchPatternType::UserLocalpart => get_localpart_from_id(user_id)?,
322317
};
323318

324-
self.match_exact_event_property_contains(
319+
self.match_event_property_contains(
325320
exact_event_match.key.clone(),
326321
Cow::Borrowed(&SimpleJsonValue::Str(pattern.to_string())),
327322
)?
@@ -454,17 +449,12 @@ impl PushRuleEvaluator {
454449
}
455450
}
456451

457-
/// Evaluates a `exact_event_property_contains` condition. (MSC3966)
458-
fn match_exact_event_property_contains(
452+
/// Evaluates a `event_property_contains` condition.
453+
fn match_event_property_contains(
459454
&self,
460455
key: Cow<str>,
461456
value: Cow<SimpleJsonValue>,
462457
) -> Result<bool, Error> {
463-
// First check if the feature is enabled.
464-
if !self.msc3966_exact_event_property_contains {
465-
return Ok(false);
466-
}
467-
468458
let haystack = if let Some(JsonValue::Array(haystack)) = self.flattened_keys.get(&*key) {
469459
haystack
470460
} else {
@@ -515,7 +505,6 @@ fn push_rule_evaluator() {
515505
true,
516506
vec![],
517507
true,
518-
true,
519508
)
520509
.unwrap();
521510

@@ -545,7 +534,6 @@ fn test_requires_room_version_supports_condition() {
545534
false,
546535
flags,
547536
true,
548-
true,
549537
)
550538
.unwrap();
551539

rust/src/push/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,9 @@ pub enum KnownCondition {
337337
// Identical to related_event_match but gives predefined patterns. Cannot be added by users.
338338
#[serde(skip_deserializing, rename = "im.nheko.msc3664.related_event_match")]
339339
RelatedEventMatchType(RelatedEventMatchTypeCondition),
340-
#[serde(rename = "org.matrix.msc3966.exact_event_property_contains")]
341-
ExactEventPropertyContains(EventPropertyIsCondition),
340+
EventPropertyContains(EventPropertyIsCondition),
342341
// Identical to exact_event_property_contains but gives predefined patterns. Cannot be added by users.
343-
#[serde(
344-
skip_deserializing,
345-
rename = "org.matrix.msc3966.exact_event_property_contains"
346-
)]
342+
#[serde(skip_deserializing, rename = "event_property_contains")]
347343
ExactEventPropertyContainsType(EventPropertyIsTypeCondition),
348344
ContainsDisplayName,
349345
RoomMemberCount {

stubs/synapse/synapse_rust/push.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class PushRuleEvaluator:
6565
related_event_match_enabled: bool,
6666
room_version_feature_flags: Tuple[str, ...],
6767
msc3931_enabled: bool,
68-
msc3966_exact_event_property_contains: bool,
6968
): ...
7069
def run(
7170
self,

synapse/config/experimental.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,9 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:
174174
"msc3873_escape_event_match_key", False
175175
)
176176

177-
# MSC3966: exact_event_property_contains push rule condition.
178-
self.msc3966_exact_event_property_contains = experimental.get(
179-
"msc3966_exact_event_property_contains", False
180-
)
181-
182177
# MSC3952: Intentional mentions, this depends on MSC3966.
183-
self.msc3952_intentional_mentions = (
184-
experimental.get("msc3952_intentional_mentions", False)
185-
and self.msc3966_exact_event_property_contains
178+
self.msc3952_intentional_mentions = experimental.get(
179+
"msc3952_intentional_mentions", False
186180
)
187181

188182
# MSC3959: Do not generate notifications for edits.

synapse/push/bulk_push_rule_evaluator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ async def _action_for_event_by_user(
413413
self._related_event_match_enabled,
414414
event.room_version.msc3931_push_features,
415415
self.hs.config.experimental.msc1767_enabled, # MSC3931 flag
416-
self.hs.config.experimental.msc3966_exact_event_property_contains,
417416
)
418417

419418
users = rules_by_user.keys()

tests/push/test_bulk_push_rule_evaluator.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,7 @@ def _create_and_process(
228228
)
229229
return len(result) > 0
230230

231-
@override_config(
232-
{
233-
"experimental_features": {
234-
"msc3952_intentional_mentions": True,
235-
"msc3966_exact_event_property_contains": True,
236-
}
237-
}
238-
)
231+
@override_config({"experimental_features": {"msc3952_intentional_mentions": True}})
239232
def test_user_mentions(self) -> None:
240233
"""Test the behavior of an event which includes invalid user mentions."""
241234
bulk_evaluator = BulkPushRuleEvaluator(self.hs)
@@ -331,14 +324,7 @@ def test_user_mentions(self) -> None:
331324
)
332325
)
333326

334-
@override_config(
335-
{
336-
"experimental_features": {
337-
"msc3952_intentional_mentions": True,
338-
"msc3966_exact_event_property_contains": True,
339-
}
340-
}
341-
)
327+
@override_config({"experimental_features": {"msc3952_intentional_mentions": True}})
342328
def test_room_mentions(self) -> None:
343329
"""Test the behavior of an event which includes invalid room mentions."""
344330
bulk_evaluator = BulkPushRuleEvaluator(self.hs)

tests/push/test_push_rule_evaluator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ def _get_evaluator(
173173
related_event_match_enabled=True,
174174
room_version_feature_flags=event.room_version.msc3931_push_features,
175175
msc3931_enabled=True,
176-
msc3966_exact_event_property_contains=True,
177176
)
178177

179178
def test_display_name(self) -> None:
@@ -526,7 +525,7 @@ def test_exact_event_property_contains(self) -> None:
526525
"""Check that exact_event_property_contains conditions work as expected."""
527526

528527
condition = {
529-
"kind": "org.matrix.msc3966.exact_event_property_contains",
528+
"kind": "event_property_contains",
530529
"key": "content.value",
531530
"value": "foobaz",
532531
}

0 commit comments

Comments
 (0)