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

Commit ded8f3d

Browse files
authored
Update the base rules to remove the dont_notify action. (MSC3987) (#15534)
A dont_notify action is a no-op (and coalesce is undefined). These are both considered no-ops by the spec, per MSC3987 and the predefined push rules were updated to remove dont_notify from the list of actions.
1 parent cc872ea commit ded8f3d

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

changelog.d/15534.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implement [MSC3987](https://github.com/matrix-org/matrix-spec-proposals/pull/3987) by removing `"dont_notify"` from the list of actions in default push rules.

rust/src/push/base_rules.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub const BASE_PREPEND_OVERRIDE_RULES: &[PushRule] = &[PushRule {
5757
rule_id: Cow::Borrowed("global/override/.m.rule.master"),
5858
priority_class: 5,
5959
conditions: Cow::Borrowed(&[]),
60-
actions: Cow::Borrowed(&[Action::DontNotify]),
60+
actions: Cow::Borrowed(&[]),
6161
default: true,
6262
default_enabled: false,
6363
}];
@@ -88,7 +88,7 @@ pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
8888
pattern: Cow::Borrowed("m.notice"),
8989
},
9090
))]),
91-
actions: Cow::Borrowed(&[Action::DontNotify]),
91+
actions: Cow::Borrowed(&[]),
9292
default: true,
9393
default_enabled: true,
9494
},
@@ -122,7 +122,7 @@ pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
122122
pattern: Cow::Borrowed("m.room.member"),
123123
},
124124
))]),
125-
actions: Cow::Borrowed(&[Action::DontNotify]),
125+
actions: Cow::Borrowed(&[]),
126126
default: true,
127127
default_enabled: true,
128128
},

rust/src/push/evaluator.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl PushRuleEvaluator {
140140
/// name.
141141
///
142142
/// Returns the set of actions, if any, that match (filtering out any
143-
/// `dont_notify` actions).
143+
/// `dont_notify` and `coalesce` actions).
144144
pub fn run(
145145
&self,
146146
push_rules: &FilteredPushRules,
@@ -198,8 +198,9 @@ impl PushRuleEvaluator {
198198
let actions = push_rule
199199
.actions
200200
.iter()
201-
// Filter out "dont_notify" actions, as we don't store them.
202-
.filter(|a| **a != Action::DontNotify)
201+
// Filter out "dont_notify" and "coalesce" actions, as we don't store them
202+
// (since they result in no action by the pushers).
203+
.filter(|a| **a != Action::DontNotify && **a != Action::Coalesce)
203204
.cloned()
204205
.collect();
205206

rust/src/push/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ impl PushRule {
164164
/// The "action" Synapse should perform for a matching push rule.
165165
#[derive(Debug, Clone, PartialEq, Eq)]
166166
pub enum Action {
167-
DontNotify,
168167
Notify,
169-
Coalesce,
170168
SetTweak(SetTweak),
171169

170+
// Legacy actions that should be understood, but are equivalent to no-ops.
171+
DontNotify,
172+
Coalesce,
173+
172174
// An unrecognized custom action.
173175
Unknown(Value),
174176
}

synapse/handlers/push_rules.py

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ def check_actions(actions: List[Union[str, JsonDict]]) -> None:
129129
raise InvalidRuleException("No actions found")
130130

131131
for a in actions:
132+
# "dont_notify" and "coalesce" are legacy actions. They are allowed, but
133+
# ignored (resulting in no action from the pusher).
132134
if a in ["notify", "dont_notify", "coalesce"]:
133135
pass
134136
elif isinstance(a, dict) and "set_tweak" in a:

0 commit comments

Comments
 (0)