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

Commit 97a3d18

Browse files
committed
Comments
1 parent 9924671 commit 97a3d18

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

synapse/push/baserules.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,40 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
"""
18+
Push rules is the system used to determine which events trigger a push (and a
19+
bump in notification counts).
20+
21+
This consists of a list of "push rules" for each user, where a push rule is a
22+
pair of "conditions" and "actions". When a user receives an event Synapse
23+
iterates over the list of push rules until it finds one where all the conditions
24+
match the event, at which point "actions" describe the outcome (e.g. notify,
25+
highlight, etc).
26+
27+
Push rules are split up into 5 different "kinds" (aka "priority classes"), which
28+
are run in order:
29+
1. Override — highest priority rules, e.g. always ignore notices
30+
2. Content — content specific rules, e.g. @ notifications
31+
3. Room — per room rules, e.g. enable/disable notifications for all messages
32+
in a room
33+
4. Sender — per sender rules, e.g. never notify for messages from a given
34+
user
35+
5. Underride — the lowest priority "default" rules, e.g. notify for every
36+
message.
37+
38+
The set of "base rules" are the list of rules that every user has by default. A
39+
user can modify their copy of the push rules in one of three ways:
40+
41+
1. Adding a new push rule of a certain kind
42+
2. Changing the actions of a base rule
43+
3. Enabling/disabling a base rule.
44+
45+
The base rules are split into whether they come before or after a particular
46+
kind, so the order of push rule evaluation would be: base rules for before
47+
"override" kind, user defined "override" rules, base rules after "override"
48+
kind, etc, etc.
49+
"""
50+
1751
import itertools
1852
from typing import Dict, Iterator, List, Mapping, Sequence, Tuple, Union
1953

@@ -25,6 +59,18 @@
2559

2660
@attr.s(auto_attribs=True, slots=True, frozen=True)
2761
class PushRule:
62+
"""A push rule
63+
64+
Attributes:
65+
rule_id: a unique ID for this rule
66+
priority_class: what "kind" of push rule this is (see
67+
`PRIORITY_CLASS_MAP` for mapping between int and kind)
68+
conditions: the sequence of conditions that all need to match
69+
actions: the actions to apply if all conditions are met
70+
default: is this a base rule?
71+
default_enabled: is this enabled by default?
72+
"""
73+
2874
rule_id: str
2975
priority_class: int
3076
conditions: Sequence[Mapping[str, str]]

0 commit comments

Comments
 (0)