Implement MSC4028: push all encrypted events. (#16361)
This unstable push rule is implemented behind an experimental configuration flag.
This commit is contained in:
parent
06f650f5f4
commit
17800a0e97
|
@ -0,0 +1 @@
|
||||||
|
Experimental support for [MSC4028](https://github.com/matrix-org/matrix-spec-proposals/pull/4028) to push all encrypted events to clients.
|
|
@ -197,6 +197,7 @@ fn bench_eval_message(b: &mut Bencher) {
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
b.iter(|| eval.run(&rules, Some("bob"), Some("person")));
|
b.iter(|| eval.run(&rules, Some("bob"), Some("person")));
|
||||||
|
|
|
@ -63,6 +63,19 @@ pub const BASE_PREPEND_OVERRIDE_RULES: &[PushRule] = &[PushRule {
|
||||||
}];
|
}];
|
||||||
|
|
||||||
pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
|
pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
|
||||||
|
PushRule {
|
||||||
|
rule_id: Cow::Borrowed("global/override/.org.matrix.msc4028.encrypted_event"),
|
||||||
|
priority_class: 5,
|
||||||
|
conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
|
||||||
|
EventMatchCondition {
|
||||||
|
key: Cow::Borrowed("type"),
|
||||||
|
pattern: Cow::Borrowed("m.room.encrypted"),
|
||||||
|
},
|
||||||
|
))]),
|
||||||
|
actions: Cow::Borrowed(&[Action::Notify]),
|
||||||
|
default: true,
|
||||||
|
default_enabled: false,
|
||||||
|
},
|
||||||
PushRule {
|
PushRule {
|
||||||
rule_id: Cow::Borrowed("global/override/.m.rule.suppress_notices"),
|
rule_id: Cow::Borrowed("global/override/.m.rule.suppress_notices"),
|
||||||
priority_class: 5,
|
priority_class: 5,
|
||||||
|
|
|
@ -564,7 +564,7 @@ fn test_requires_room_version_supports_condition() {
|
||||||
};
|
};
|
||||||
let rules = PushRules::new(vec![custom_rule]);
|
let rules = PushRules::new(vec![custom_rule]);
|
||||||
result = evaluator.run(
|
result = evaluator.run(
|
||||||
&FilteredPushRules::py_new(rules, BTreeMap::new(), true, false, true),
|
&FilteredPushRules::py_new(rules, BTreeMap::new(), true, false, true, false),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
|
@ -527,6 +527,7 @@ pub struct FilteredPushRules {
|
||||||
msc1767_enabled: bool,
|
msc1767_enabled: bool,
|
||||||
msc3381_polls_enabled: bool,
|
msc3381_polls_enabled: bool,
|
||||||
msc3664_enabled: bool,
|
msc3664_enabled: bool,
|
||||||
|
msc4028_push_encrypted_events: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pymethods]
|
#[pymethods]
|
||||||
|
@ -538,6 +539,7 @@ impl FilteredPushRules {
|
||||||
msc1767_enabled: bool,
|
msc1767_enabled: bool,
|
||||||
msc3381_polls_enabled: bool,
|
msc3381_polls_enabled: bool,
|
||||||
msc3664_enabled: bool,
|
msc3664_enabled: bool,
|
||||||
|
msc4028_push_encrypted_events: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
push_rules,
|
push_rules,
|
||||||
|
@ -545,6 +547,7 @@ impl FilteredPushRules {
|
||||||
msc1767_enabled,
|
msc1767_enabled,
|
||||||
msc3381_polls_enabled,
|
msc3381_polls_enabled,
|
||||||
msc3664_enabled,
|
msc3664_enabled,
|
||||||
|
msc4028_push_encrypted_events,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,6 +584,12 @@ impl FilteredPushRules {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.msc4028_push_encrypted_events
|
||||||
|
&& rule.rule_id == "global/override/.org.matrix.msc4028.encrypted_event"
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.map(|r| {
|
.map(|r| {
|
||||||
|
|
|
@ -46,6 +46,7 @@ class FilteredPushRules:
|
||||||
msc1767_enabled: bool,
|
msc1767_enabled: bool,
|
||||||
msc3381_polls_enabled: bool,
|
msc3381_polls_enabled: bool,
|
||||||
msc3664_enabled: bool,
|
msc3664_enabled: bool,
|
||||||
|
msc4028_push_encrypted_events: bool,
|
||||||
): ...
|
): ...
|
||||||
def rules(self) -> Collection[Tuple[PushRule, bool]]: ...
|
def rules(self) -> Collection[Tuple[PushRule, bool]]: ...
|
||||||
|
|
||||||
|
|
|
@ -415,3 +415,7 @@ class ExperimentalConfig(Config):
|
||||||
LimitExceededError.include_retry_after_header = experimental.get(
|
LimitExceededError.include_retry_after_header = experimental.get(
|
||||||
"msc4041_enabled", False
|
"msc4041_enabled", False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.msc4028_push_encrypted_events = experimental.get(
|
||||||
|
"msc4028_push_encrypted_events", False
|
||||||
|
)
|
||||||
|
|
|
@ -88,6 +88,7 @@ def _load_rules(
|
||||||
msc1767_enabled=experimental_config.msc1767_enabled,
|
msc1767_enabled=experimental_config.msc1767_enabled,
|
||||||
msc3664_enabled=experimental_config.msc3664_enabled,
|
msc3664_enabled=experimental_config.msc3664_enabled,
|
||||||
msc3381_polls_enabled=experimental_config.msc3381_polls_enabled,
|
msc3381_polls_enabled=experimental_config.msc3381_polls_enabled,
|
||||||
|
msc4028_push_encrypted_events=experimental_config.msc4028_push_encrypted_events,
|
||||||
)
|
)
|
||||||
|
|
||||||
return filtered_rules
|
return filtered_rules
|
||||||
|
|
Loading…
Reference in New Issue