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

Commit c135941

Browse files
committed
Merge remote-tracking branch 'origin/develop' into rei/frrj_workers_complement
2 parents 4d1a4f0 + a7b54ca commit c135941

File tree

12 files changed

+120
-14
lines changed

12 files changed

+120
-14
lines changed

changelog.d/14787.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implement experimental support for MSC3930: Push rules for (MSC3381) Polls.

changelog.d/14868.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Minor corrections to the logging configuration documentation.

docker/complement/conf/workers-shared-extra.yaml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ experimental_features:
100100
faster_joins: true
101101
# Filtering /messages by relation type.
102102
msc3874_enabled: true
103+
# Enable support for polls
104+
msc3381_polls_enabled: true
103105
# Enable deleting device-specific notification settings stored in account data
104106
msc3890_enabled: true
105107
# Enable removing account data support
106108
msc3391_enabled: true
109+
# Filtering /messages by relation type.
110+
msc3874_enabled: true
107111

108112
server_notices:
109113
system_mxid_localpart: _server

docs/usage/configuration/logging_sample_config.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Logging Sample Configuration File
22

33
Below is a sample logging configuration file. This file can be tweaked to control how your
4-
homeserver will output logs. A restart of the server is generally required to apply any
5-
changes made to this file. The value of the `log_config` option in your homeserver
6-
config should be the path to this file.
4+
homeserver will output logs. The value of the `log_config` option in your homeserver config
5+
should be the path to this file.
6+
7+
To apply changes made to this file, send Synapse a SIGHUP signal (or, if using `systemd`, run
8+
`systemctl reload` on the Synapse service).
79

810
Note that a default logging configuration (shown below) is created automatically alongside
911
the homeserver config when following the [installation instructions](../../setup/installation.md).

rust/benches/evaluator.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,13 @@ fn bench_eval_message(b: &mut Bencher) {
150150
)
151151
.unwrap();
152152

153-
let rules =
154-
FilteredPushRules::py_new(PushRules::new(Vec::new()), Default::default(), false, false);
153+
let rules = FilteredPushRules::py_new(
154+
PushRules::new(Vec::new()),
155+
Default::default(),
156+
false,
157+
false,
158+
false,
159+
);
155160

156161
b.iter(|| eval.run(&rules, Some("bob"), Some("person")));
157162
}

rust/src/push/base_rules.rs

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2022 The Matrix.org Foundation C.I.C.
1+
// Copyright 2022, 2023 The Matrix.org Foundation C.I.C.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -208,6 +208,20 @@ pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
208208
default: true,
209209
default_enabled: true,
210210
},
211+
PushRule {
212+
rule_id: Cow::Borrowed("global/override/.org.matrix.msc3930.rule.poll_response"),
213+
priority_class: 5,
214+
conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
215+
EventMatchCondition {
216+
key: Cow::Borrowed("type"),
217+
pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.response")),
218+
pattern_type: None,
219+
},
220+
))]),
221+
actions: Cow::Borrowed(&[]),
222+
default: true,
223+
default_enabled: true,
224+
},
211225
];
212226

213227
pub const BASE_APPEND_CONTENT_RULES: &[PushRule] = &[PushRule {
@@ -596,6 +610,68 @@ pub const BASE_APPEND_UNDERRIDE_RULES: &[PushRule] = &[
596610
default: true,
597611
default_enabled: true,
598612
},
613+
PushRule {
614+
rule_id: Cow::Borrowed("global/underride/.org.matrix.msc3930.rule.poll_start_one_to_one"),
615+
priority_class: 1,
616+
conditions: Cow::Borrowed(&[
617+
Condition::Known(KnownCondition::RoomMemberCount {
618+
is: Some(Cow::Borrowed("2")),
619+
}),
620+
Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
621+
key: Cow::Borrowed("type"),
622+
pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.start")),
623+
pattern_type: None,
624+
})),
625+
]),
626+
actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION]),
627+
default: true,
628+
default_enabled: true,
629+
},
630+
PushRule {
631+
rule_id: Cow::Borrowed("global/underride/.org.matrix.msc3930.rule.poll_start"),
632+
priority_class: 1,
633+
conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
634+
EventMatchCondition {
635+
key: Cow::Borrowed("type"),
636+
pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.start")),
637+
pattern_type: None,
638+
},
639+
))]),
640+
actions: Cow::Borrowed(&[Action::Notify]),
641+
default: true,
642+
default_enabled: true,
643+
},
644+
PushRule {
645+
rule_id: Cow::Borrowed("global/underride/.org.matrix.msc3930.rule.poll_end_one_to_one"),
646+
priority_class: 1,
647+
conditions: Cow::Borrowed(&[
648+
Condition::Known(KnownCondition::RoomMemberCount {
649+
is: Some(Cow::Borrowed("2")),
650+
}),
651+
Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
652+
key: Cow::Borrowed("type"),
653+
pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.end")),
654+
pattern_type: None,
655+
})),
656+
]),
657+
actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION]),
658+
default: true,
659+
default_enabled: true,
660+
},
661+
PushRule {
662+
rule_id: Cow::Borrowed("global/underride/.org.matrix.msc3930.rule.poll_end"),
663+
priority_class: 1,
664+
conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
665+
EventMatchCondition {
666+
key: Cow::Borrowed("type"),
667+
pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.end")),
668+
pattern_type: None,
669+
},
670+
))]),
671+
actions: Cow::Borrowed(&[Action::Notify]),
672+
default: true,
673+
default_enabled: true,
674+
},
599675
];
600676

601677
lazy_static! {

rust/src/push/evaluator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ fn test_requires_room_version_supports_condition() {
483483
};
484484
let rules = PushRules::new(vec![custom_rule]);
485485
result = evaluator.run(
486-
&FilteredPushRules::py_new(rules, BTreeMap::new(), true, true),
486+
&FilteredPushRules::py_new(rules, BTreeMap::new(), true, false, true),
487487
None,
488488
None,
489489
);

rust/src/push/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,9 @@ impl PushRules {
411411
pub struct FilteredPushRules {
412412
push_rules: PushRules,
413413
enabled_map: BTreeMap<String, bool>,
414-
msc3664_enabled: bool,
415414
msc1767_enabled: bool,
415+
msc3381_polls_enabled: bool,
416+
msc3664_enabled: bool,
416417
}
417418

418419
#[pymethods]
@@ -421,14 +422,16 @@ impl FilteredPushRules {
421422
pub fn py_new(
422423
push_rules: PushRules,
423424
enabled_map: BTreeMap<String, bool>,
424-
msc3664_enabled: bool,
425425
msc1767_enabled: bool,
426+
msc3381_polls_enabled: bool,
427+
msc3664_enabled: bool,
426428
) -> Self {
427429
Self {
428430
push_rules,
429431
enabled_map,
430-
msc3664_enabled,
431432
msc1767_enabled,
433+
msc3381_polls_enabled,
434+
msc3664_enabled,
432435
}
433436
}
434437

@@ -447,13 +450,18 @@ impl FilteredPushRules {
447450
.iter()
448451
.filter(|rule| {
449452
// Ignore disabled experimental push rules
453+
454+
if !self.msc1767_enabled && rule.rule_id.contains("org.matrix.msc1767") {
455+
return false;
456+
}
457+
450458
if !self.msc3664_enabled
451459
&& rule.rule_id == "global/override/.im.nheko.msc3664.reply"
452460
{
453461
return false;
454462
}
455463

456-
if !self.msc1767_enabled && rule.rule_id.contains("org.matrix.msc1767") {
464+
if !self.msc3381_polls_enabled && rule.rule_id.contains("org.matrix.msc3930") {
457465
return false;
458466
}
459467

scripts-dev/complement.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fi
190190

191191
extra_test_args=()
192192

193-
test_tags="synapse_blacklist,msc3787,msc3874,msc3890,msc3391,faster_joins"
193+
test_tags="synapse_blacklist,msc3787,msc3874,msc3890,msc3391,msc3930,faster_joins"
194194

195195
# All environment variables starting with PASS_ will be shared.
196196
# (The prefix is stripped off before reaching the container.)

stubs/synapse/synapse_rust/push.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ class FilteredPushRules:
4343
self,
4444
push_rules: PushRules,
4545
enabled_map: Dict[str, bool],
46-
msc3664_enabled: bool,
4746
msc1767_enabled: bool,
47+
msc3381_polls_enabled: bool,
48+
msc3664_enabled: bool,
4849
): ...
4950
def rules(self) -> Collection[Tuple[PushRule, bool]]: ...
5051

0 commit comments

Comments
 (0)