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

Commit

Permalink
Add an experimental config option.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Jan 12, 2023
1 parent c9d2a3d commit 7388728
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rust/src/push/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ pub struct FilteredPushRules {
enabled_map: BTreeMap<String, bool>,
msc3664_enabled: bool,
msc1767_enabled: bool,
msc3952_intentional_mentions: bool,
}

#[pymethods]
Expand All @@ -427,12 +428,14 @@ impl FilteredPushRules {
enabled_map: BTreeMap<String, bool>,
msc3664_enabled: bool,
msc1767_enabled: bool,
msc3952_intentional_mentions: bool,
) -> Self {
Self {
push_rules,
enabled_map,
msc3664_enabled,
msc1767_enabled,
msc3952_intentional_mentions,
}
}

Expand Down Expand Up @@ -461,6 +464,11 @@ impl FilteredPushRules {
return false;
}

if !self.msc3952_intentional_mentions && rule.rule_id.contains("org.matrix.msc3952")
{
return false;
}

true
})
.map(|r| {
Expand Down
1 change: 1 addition & 0 deletions stubs/synapse/synapse_rust/push.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class FilteredPushRules:
enabled_map: Dict[str, bool],
msc3664_enabled: bool,
msc1767_enabled: bool,
msc3952_intentional_mentions: bool,
): ...
def rules(self) -> Collection[Tuple[PushRule, bool]]: ...

Expand Down
5 changes: 5 additions & 0 deletions synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,8 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:

# MSC3925: do not replace events with their edits
self.msc3925_inhibit_edit = experimental.get("msc3925_inhibit_edit", False)

# MSC3952: Intentional mentions
self.msc3952_intentional_mentions = experimental.get(
"msc3952_intentional_mentions", False
)
1 change: 1 addition & 0 deletions synapse/storage/databases/main/push_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def _load_rules(
enabled_map,
msc3664_enabled=experimental_config.msc3664_enabled,
msc1767_enabled=experimental_config.msc1767_enabled,
msc3952_intentional_mentions=experimental_config.msc3952_intentional_mentions,
)

return filtered_rules
Expand Down

0 comments on commit 7388728

Please sign in to comment.