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

Implement MSC3930: polls push rules #14787

Merged
merged 12 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Organise MSC* arguments alphabetically
  • Loading branch information
anoadragon453 committed Jan 11, 2023
commit b63b2ff98269d629db93aafa835725360efdada2
4 changes: 2 additions & 2 deletions docker/complement/conf/workers-shared-extra.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ experimental_features:
# client-side support for partial state in /send_join responses
faster_joins: true
{% endif %}
# Filtering /messages by relation type.
msc3874_enabled: true
# Enable removing account data support
msc3391_enabled: true
# Filtering /messages by relation type.
msc3874_enabled: true
# Enable push rules for polls
msc3930_enabled: true

Expand Down
29 changes: 15 additions & 14 deletions rust/src/push/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,9 @@ impl PushRules {
pub struct FilteredPushRules {
push_rules: PushRules,
enabled_map: BTreeMap<String, bool>,
msc3930_enabled: bool,
msc3664_enabled: bool,
msc1767_enabled: bool,
msc3664_enabled: bool,
msc3930_enabled: bool,
}

#[pymethods]
Expand All @@ -422,16 +422,16 @@ impl FilteredPushRules {
pub fn py_new(
push_rules: PushRules,
enabled_map: BTreeMap<String, bool>,
msc3930_enabled: bool,
msc3664_enabled: bool,
msc1767_enabled: bool,
msc3664_enabled: bool,
msc3930_enabled: bool,
) -> Self {
Self {
push_rules,
enabled_map,
msc3930_enabled,
msc3664_enabled,
msc1767_enabled,
msc3664_enabled,
msc3930_enabled,
}
}

Expand All @@ -450,13 +450,8 @@ impl FilteredPushRules {
.iter()
.filter(|rule| {
// Ignore disabled experimental push rules
if !self.msc3930_enabled
&& (rule.rule_id == "global/override/.org.matrix.msc3930.rule.poll_response"
|| rule.rule_id == "global/underride/.org.matrix.msc3930.rule.poll_start_one_to_one"
|| rule.rule_id == "global/underride/.org.matrix.msc3930.rule.poll_start"
|| rule.rule_id == "global/underride/.org.matrix.msc3930.rule.poll_end_one_to_one"
|| rule.rule_id == "global/underride/.org.matrix.msc3930.rule.poll_end")
{

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

Expand All @@ -466,7 +461,13 @@ impl FilteredPushRules {
return false;
}

if !self.msc1767_enabled && rule.rule_id.contains("org.matrix.msc1767") {
if !self.msc3930_enabled
&& (rule.rule_id == "global/override/.org.matrix.msc3930.rule.poll_response"
|| rule.rule_id == "global/underride/.org.matrix.msc3930.rule.poll_start_one_to_one"
|| rule.rule_id == "global/underride/.org.matrix.msc3930.rule.poll_start"
|| rule.rule_id == "global/underride/.org.matrix.msc3930.rule.poll_end_one_to_one"
|| rule.rule_id == "global/underride/.org.matrix.msc3930.rule.poll_end")
{
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions stubs/synapse/synapse_rust/push.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class FilteredPushRules:
self,
push_rules: PushRules,
enabled_map: Dict[str, bool],
msc3930_enabled: bool,
msc3664_enabled: bool,
msc1767_enabled: bool,
msc3664_enabled: bool,
msc3930_enabled: bool,
): ...
def rules(self) -> Collection[Tuple[PushRule, bool]]: ...

Expand Down
4 changes: 2 additions & 2 deletions synapse/storage/databases/main/push_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def _load_rules(
filtered_rules = FilteredPushRules(
push_rules,
enabled_map,
msc3930_enabled=experimental_config.msc3930_enabled,
msc3664_enabled=experimental_config.msc3664_enabled,
msc1767_enabled=experimental_config.msc1767_enabled,
msc3664_enabled=experimental_config.msc3664_enabled,
msc3930_enabled=experimental_config.msc3930_enabled,
)

return filtered_rules
Expand Down