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

Commit 5296f39

Browse files
committed
Remove the is_room_mention support.
1 parent a7e64a8 commit 5296f39

File tree

7 files changed

+8
-53
lines changed

7 files changed

+8
-53
lines changed

rust/benches/evaluator.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ fn bench_match_exact(b: &mut Bencher) {
4545
flattened_keys,
4646
false,
4747
BTreeSet::new(),
48-
false,
4948
10,
5049
Some(0),
5150
Default::default(),
@@ -94,7 +93,6 @@ fn bench_match_word(b: &mut Bencher) {
9493
flattened_keys,
9594
false,
9695
BTreeSet::new(),
97-
false,
9896
10,
9997
Some(0),
10098
Default::default(),
@@ -143,7 +141,6 @@ fn bench_match_word_miss(b: &mut Bencher) {
143141
flattened_keys,
144142
false,
145143
BTreeSet::new(),
146-
false,
147144
10,
148145
Some(0),
149146
Default::default(),
@@ -192,7 +189,6 @@ fn bench_eval_message(b: &mut Bencher) {
192189
flattened_keys,
193190
false,
194191
BTreeSet::new(),
195-
false,
196192
10,
197193
Some(0),
198194
Default::default(),

rust/src/push/evaluator.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ pub struct PushRuleEvaluator {
7272
has_mentions: bool,
7373
/// The user mentions that were part of the message.
7474
user_mentions: BTreeSet<String>,
75-
/// True if the message is a room message.
76-
room_mention: bool,
7775

7876
/// The number of users in the room.
7977
room_member_count: u64,
@@ -112,7 +110,6 @@ impl PushRuleEvaluator {
112110
flattened_keys: BTreeMap<String, SimpleJsonValue>,
113111
has_mentions: bool,
114112
user_mentions: BTreeSet<String>,
115-
room_mention: bool,
116113
room_member_count: u64,
117114
sender_power_level: Option<i64>,
118115
notification_power_levels: BTreeMap<String, i64>,
@@ -132,7 +129,6 @@ impl PushRuleEvaluator {
132129
body,
133130
has_mentions,
134131
user_mentions,
135-
room_mention,
136132
room_member_count,
137133
notification_power_levels,
138134
sender_power_level,
@@ -270,7 +266,6 @@ impl PushRuleEvaluator {
270266
false
271267
}
272268
}
273-
KnownCondition::IsRoomMention => self.room_mention,
274269
KnownCondition::ContainsDisplayName => {
275270
if let Some(dn) = display_name {
276271
if !dn.is_empty() {
@@ -494,7 +489,6 @@ fn push_rule_evaluator() {
494489
flattened_keys,
495490
false,
496491
BTreeSet::new(),
497-
false,
498492
10,
499493
Some(0),
500494
BTreeMap::new(),
@@ -526,7 +520,6 @@ fn test_requires_room_version_supports_condition() {
526520
flattened_keys,
527521
false,
528522
BTreeSet::new(),
529-
false,
530523
10,
531524
Some(0),
532525
BTreeMap::new(),

rust/src/push/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,6 @@ pub enum KnownCondition {
305305
RelatedEventMatch(RelatedEventMatchCondition),
306306
#[serde(rename = "org.matrix.msc3952.is_user_mention")]
307307
IsUserMention,
308-
#[serde(rename = "org.matrix.msc3952.is_room_mention")]
309-
IsRoomMention,
310308
ContainsDisplayName,
311309
RoomMemberCount {
312310
#[serde(skip_serializing_if = "Option::is_none")]
@@ -636,17 +634,6 @@ fn test_deserialize_unstable_msc3952_user_condition() {
636634
));
637635
}
638636

639-
#[test]
640-
fn test_deserialize_unstable_msc3952_room_condition() {
641-
let json = r#"{"kind":"org.matrix.msc3952.is_room_mention"}"#;
642-
643-
let condition: Condition = serde_json::from_str(json).unwrap();
644-
assert!(matches!(
645-
condition,
646-
Condition::Known(KnownCondition::IsRoomMention)
647-
));
648-
}
649-
650637
#[test]
651638
fn test_deserialize_custom_condition() {
652639
let json = r#"{"kind":"custom_tag"}"#;

stubs/synapse/synapse_rust/push.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class PushRuleEvaluator:
5959
flattened_keys: Mapping[str, SimpleJsonValue],
6060
has_mentions: bool,
6161
user_mentions: Set[str],
62-
room_mention: bool,
6362
room_member_count: int,
6463
sender_power_level: Optional[int],
6564
notification_power_levels: Mapping[str, int],

synapse/push/bulk_push_rule_evaluator.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ async def _action_for_event_by_user(
400400
mentions = event.content.get(EventContentFields.MSC3952_MENTIONS)
401401
has_mentions = self._intentional_mentions_enabled and isinstance(mentions, dict)
402402
user_mentions: Set[str] = set()
403-
room_mention = False
404403
if has_mentions:
405404
# mypy seems to have lost the type even though it must be a dict here.
406405
assert isinstance(mentions, dict)
@@ -410,8 +409,6 @@ async def _action_for_event_by_user(
410409
user_mentions = set(
411410
filter(lambda item: isinstance(item, str), user_mentions_raw)
412411
)
413-
# Room mention is only true if the value is exactly true.
414-
room_mention = mentions.get("room") is True
415412

416413
evaluator = PushRuleEvaluator(
417414
_flatten_dict(
@@ -420,7 +417,6 @@ async def _action_for_event_by_user(
420417
),
421418
has_mentions,
422419
user_mentions,
423-
room_mention,
424420
room_member_count,
425421
sender_power_level,
426422
notification_levels,

tests/push/test_bulk_push_rule_evaluator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,14 @@ def test_user_mentions(self) -> None:
330330
)
331331
)
332332

333-
@override_config({"experimental_features": {"msc3758_exact_event_match": True, "msc3952_intentional_mentions": True}})
333+
@override_config(
334+
{
335+
"experimental_features": {
336+
"msc3758_exact_event_match": True,
337+
"msc3952_intentional_mentions": True,
338+
}
339+
}
340+
)
334341
def test_room_mentions(self) -> None:
335342
"""Test the behavior of an event which includes invalid room mentions."""
336343
bulk_evaluator = BulkPushRuleEvaluator(self.hs)

tests/push/test_push_rule_evaluator.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ def _get_evaluator(
139139
*,
140140
has_mentions: bool = False,
141141
user_mentions: Optional[Set[str]] = None,
142-
room_mention: bool = False,
143142
related_events: Optional[JsonDict] = None,
144143
) -> PushRuleEvaluator:
145144
event = FrozenEvent(
@@ -160,7 +159,6 @@ def _get_evaluator(
160159
_flatten_dict(event),
161160
has_mentions,
162161
user_mentions or set(),
163-
room_mention,
164162
room_member_count,
165163
sender_power_level,
166164
cast(Dict[str, int], power_levels.get("notifications", {})),
@@ -221,27 +219,6 @@ def test_user_mentions(self) -> None:
221219
# Note that invalid data is tested at tests.push.test_bulk_push_rule_evaluator.TestBulkPushRuleEvaluator.test_mentions
222220
# since the BulkPushRuleEvaluator is what handles data sanitisation.
223221

224-
def test_room_mentions(self) -> None:
225-
"""Check for room mentions."""
226-
condition = {"kind": "org.matrix.msc3952.is_room_mention"}
227-
228-
# No room mention shouldn't match.
229-
evaluator = self._get_evaluator({}, has_mentions=True)
230-
self.assertFalse(evaluator.matches(condition, None, None))
231-
232-
# Room mention should match.
233-
evaluator = self._get_evaluator({}, has_mentions=True, room_mention=True)
234-
self.assertTrue(evaluator.matches(condition, None, None))
235-
236-
# A room mention and user mention is valid.
237-
evaluator = self._get_evaluator(
238-
{}, has_mentions=True, user_mentions={"@another:test"}, room_mention=True
239-
)
240-
self.assertTrue(evaluator.matches(condition, None, None))
241-
242-
# Note that invalid data is tested at tests.push.test_bulk_push_rule_evaluator.TestBulkPushRuleEvaluator.test_mentions
243-
# since the BulkPushRuleEvaluator is what handles data sanitisation.
244-
245222
def _assert_matches(
246223
self, condition: JsonDict, content: JsonMapping, msg: Optional[str] = None
247224
) -> None:

0 commit comments

Comments
 (0)