summary refs log tree commit diff
path: root/rust/src/push/mod.rs
diff options
context:
space:
mode:
authorMathieu Velten <mathieuv@matrix.org>2022-12-12 17:48:27 +0100
committerMathieu Velten <mathieuv@matrix.org>2022-12-12 17:48:27 +0100
commit4ccade636e9903c78eeba89d8487a3b3e2ba4e2f (patch)
tree8a8e732fceda8923054506689833eb447067e711 /rust/src/push/mod.rs
parentMerge remote-tracking branch 'origin/develop' into mv/unbind-callback (diff)
parentMove `StateFilter` to `synapse.types` (#14668) (diff)
downloadsynapse-4ccade636e9903c78eeba89d8487a3b3e2ba4e2f.tar.xz
Merge remote-tracking branch 'origin/develop' into mv/unbind-callback
Diffstat (limited to 'rust/src/push/mod.rs')
-rw-r--r--rust/src/push/mod.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/rust/src/push/mod.rs b/rust/src/push/mod.rs

index d57800aa4a..2e9d3e38a1 100644 --- a/rust/src/push/mod.rs +++ b/rust/src/push/mod.rs
@@ -277,6 +277,10 @@ pub enum KnownCondition { SenderNotificationPermission { key: Cow<'static, str>, }, + #[serde(rename = "org.matrix.msc3931.room_version_supports")] + RoomVersionSupports { + feature: Cow<'static, str>, + }, } impl IntoPy<PyObject> for Condition { @@ -408,6 +412,7 @@ pub struct FilteredPushRules { push_rules: PushRules, enabled_map: BTreeMap<String, bool>, msc3664_enabled: bool, + msc1767_enabled: bool, } #[pymethods] @@ -417,11 +422,13 @@ impl FilteredPushRules { push_rules: PushRules, enabled_map: BTreeMap<String, bool>, msc3664_enabled: bool, + msc1767_enabled: bool, ) -> Self { Self { push_rules, enabled_map, msc3664_enabled, + msc1767_enabled, } } @@ -446,6 +453,10 @@ impl FilteredPushRules { return false; } + if !self.msc1767_enabled && rule.rule_id.contains("org.matrix.msc1767") { + return false; + } + true }) .map(|r| { @@ -492,6 +503,18 @@ fn test_deserialize_unstable_msc3664_condition() { } #[test] +fn test_deserialize_unstable_msc3931_condition() { + let json = + r#"{"kind":"org.matrix.msc3931.room_version_supports","feature":"org.example.feature"}"#; + + let condition: Condition = serde_json::from_str(json).unwrap(); + assert!(matches!( + condition, + Condition::Known(KnownCondition::RoomVersionSupports { feature: _ }) + )); +} + +#[test] fn test_deserialize_custom_condition() { let json = r#"{"kind":"custom_tag"}"#;