mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-22 14:29:55 +00:00
Add default push rules for live location share start (MSCxxxx draft)
Underride rules .io.element.rule.beacon_info(_one_to_one) matching org.matrix.msc3672.beacon_info with content.live == true, so recipients are pushed when someone starts a live location share (incl. E2EE rooms, since beacon_info is an unencrypted state event). Gated behind experimental_features.mscxxxx_beacon_push_rules_enabled; rule ids and flag to be renamed once the MSC is numbered. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
ec6c53e7df
commit
849032d6d5
@@ -721,6 +721,43 @@ pub const BASE_APPEND_UNDERRIDE_RULES: &[PushRule] = &[
|
||||
default: true,
|
||||
default_enabled: true,
|
||||
},
|
||||
PushRule {
|
||||
rule_id: Cow::Borrowed("global/underride/.io.element.rule.beacon_info_one_to_one"),
|
||||
priority_class: 1,
|
||||
conditions: Cow::Borrowed(&[
|
||||
Condition::Known(KnownCondition::RoomMemberCount {
|
||||
is: Some(Cow::Borrowed("2")),
|
||||
}),
|
||||
Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
|
||||
key: Cow::Borrowed("type"),
|
||||
pattern: Cow::Borrowed("org.matrix.msc3672.beacon_info"),
|
||||
})),
|
||||
Condition::Known(KnownCondition::EventPropertyIs(EventPropertyIsCondition {
|
||||
key: Cow::Borrowed("content.live"),
|
||||
value: Cow::Owned(SimpleJsonValue::Bool(true)),
|
||||
})),
|
||||
]),
|
||||
actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION]),
|
||||
default: true,
|
||||
default_enabled: true,
|
||||
},
|
||||
PushRule {
|
||||
rule_id: Cow::Borrowed("global/underride/.io.element.rule.beacon_info"),
|
||||
priority_class: 1,
|
||||
conditions: Cow::Borrowed(&[
|
||||
Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
|
||||
key: Cow::Borrowed("type"),
|
||||
pattern: Cow::Borrowed("org.matrix.msc3672.beacon_info"),
|
||||
})),
|
||||
Condition::Known(KnownCondition::EventPropertyIs(EventPropertyIsCondition {
|
||||
key: Cow::Borrowed("content.live"),
|
||||
value: Cow::Owned(SimpleJsonValue::Bool(true)),
|
||||
})),
|
||||
]),
|
||||
actions: Cow::Borrowed(&[Action::Notify]),
|
||||
default: true,
|
||||
default_enabled: true,
|
||||
},
|
||||
];
|
||||
|
||||
lazy_static! {
|
||||
|
||||
@@ -637,6 +637,7 @@ fn test_requires_room_version_supports_condition() {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
),
|
||||
None,
|
||||
None,
|
||||
|
||||
@@ -559,6 +559,7 @@ pub struct FilteredPushRules {
|
||||
msc4028_push_encrypted_events: bool,
|
||||
msc4210_enabled: bool,
|
||||
msc4306_enabled: bool,
|
||||
mscxxxx_beacon_push_rules_enabled: bool,
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
@@ -574,6 +575,7 @@ impl FilteredPushRules {
|
||||
msc4028_push_encrypted_events: bool,
|
||||
msc4210_enabled: bool,
|
||||
msc4306_enabled: bool,
|
||||
mscxxxx_beacon_push_rules_enabled: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
push_rules,
|
||||
@@ -584,6 +586,7 @@ impl FilteredPushRules {
|
||||
msc4028_push_encrypted_events,
|
||||
msc4210_enabled,
|
||||
msc4306_enabled,
|
||||
mscxxxx_beacon_push_rules_enabled,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,6 +623,12 @@ impl FilteredPushRules {
|
||||
return false;
|
||||
}
|
||||
|
||||
if !self.mscxxxx_beacon_push_rules_enabled
|
||||
&& rule.rule_id.contains("/.io.element.rule.beacon_info")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if !self.msc4028_push_encrypted_events
|
||||
&& rule.rule_id == "global/override/.org.matrix.msc4028.encrypted_event"
|
||||
{
|
||||
|
||||
@@ -156,6 +156,13 @@ class ExperimentalConfig(Config):
|
||||
"msc3381_polls_enabled", False
|
||||
)
|
||||
|
||||
# MSCXXXX (unnumbered draft): default push rules for live location share
|
||||
# beacon_info start events (the MSC3672 state event). Unstable rule ids:
|
||||
# .io.element.rule.beacon_info(_one_to_one).
|
||||
self.mscxxxx_beacon_push_rules_enabled: bool = experimental.get(
|
||||
"mscxxxx_beacon_push_rules_enabled", False
|
||||
)
|
||||
|
||||
# MSC3912: Relation-based redactions.
|
||||
self.msc3912_enabled: bool = experimental.get("msc3912_enabled", False)
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ def _load_rules(
|
||||
msc4028_push_encrypted_events=experimental_config.msc4028_push_encrypted_events,
|
||||
msc4210_enabled=experimental_config.msc4210_enabled,
|
||||
msc4306_enabled=experimental_config.msc4306_enabled,
|
||||
mscxxxx_beacon_push_rules_enabled=experimental_config.mscxxxx_beacon_push_rules_enabled,
|
||||
)
|
||||
|
||||
return filtered_rules
|
||||
|
||||
@@ -50,6 +50,7 @@ class FilteredPushRules:
|
||||
msc4028_push_encrypted_events: bool,
|
||||
msc4210_enabled: bool,
|
||||
msc4306_enabled: bool,
|
||||
mscxxxx_beacon_push_rules_enabled: bool,
|
||||
): ...
|
||||
def rules(self) -> Collection[tuple[PushRule, bool]]: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user