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

Update the base rules to remove the dont_notify action. (MSC3987) #15534

Merged
merged 4 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/15534.misc
Original file line number Diff line number Diff line change
@@ -0,0 +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.
6 changes: 3 additions & 3 deletions rust/src/push/base_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub const BASE_PREPEND_OVERRIDE_RULES: &[PushRule] = &[PushRule {
rule_id: Cow::Borrowed("global/override/.m.rule.master"),
priority_class: 5,
conditions: Cow::Borrowed(&[]),
actions: Cow::Borrowed(&[Action::DontNotify]),
actions: Cow::Borrowed(&[]),
default: true,
default_enabled: false,
}];
Expand Down Expand Up @@ -88,7 +88,7 @@ pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
pattern: Cow::Borrowed("m.notice"),
},
))]),
actions: Cow::Borrowed(&[Action::DontNotify]),
actions: Cow::Borrowed(&[]),
default: true,
default_enabled: true,
},
Expand Down Expand Up @@ -122,7 +122,7 @@ pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
pattern: Cow::Borrowed("m.room.member"),
},
))]),
actions: Cow::Borrowed(&[Action::DontNotify]),
actions: Cow::Borrowed(&[]),
default: true,
default_enabled: true,
},
Expand Down
7 changes: 4 additions & 3 deletions rust/src/push/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl PushRuleEvaluator {
/// name.
///
/// Returns the set of actions, if any, that match (filtering out any
/// `dont_notify` actions).
/// `dont_notify` and `coalesce` actions).
pub fn run(
&self,
push_rules: &FilteredPushRules,
Expand Down Expand Up @@ -198,8 +198,9 @@ impl PushRuleEvaluator {
let actions = push_rule
.actions
.iter()
// Filter out "dont_notify" actions, as we don't store them.
.filter(|a| **a != Action::DontNotify)
// Filter out "dont_notify" and "coalesce" actions, as we don't store them
// (since they result in no action by the pushers).
.filter(|a| **a != Action::DontNotify && **a != Action::Coalesce)
Comment on lines +201 to +203
Copy link
Member Author

@clokep clokep May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushers only care about notify and then tweaks, see

if "notify" not in push_action.actions:
return True
tweaks = tweaks_for_actions(push_action.actions)

.cloned()
.collect();

Expand Down
6 changes: 4 additions & 2 deletions rust/src/push/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ impl PushRule {
/// The "action" Synapse should perform for a matching push rule.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Action {
DontNotify,
Notify,
Coalesce,
SetTweak(SetTweak),

// Legacy actions that should be understood, but are equivalent to no-ops.
DontNotify,
Coalesce,

// An unrecognized custom action.
Unknown(Value),
}
Expand Down
2 changes: 2 additions & 0 deletions synapse/handlers/push_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def check_actions(actions: List[Union[str, JsonDict]]) -> None:
raise InvalidRuleException("No actions found")

for a in actions:
# "dont_notify" and "coalesce" are legacy actions. They are allowed, but
# ignored (resulting in no action from the pusher).
if a in ["notify", "dont_notify", "coalesce"]:
pass
elif isinstance(a, dict) and "set_tweak" in a:
Expand Down