mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-23 12:11:34 +00:00
f47515e38b
This should fix https://github.com/matrix-org/dendrite/issues/2882 (Tested with FluffyChat 1.7.1) Also adds tests that the predefined push rules (as per the spec) is what we have in Dendrite.
72 lines
2.1 KiB
Go
72 lines
2.1 KiB
Go
package pushrules
|
|
|
|
// An AccountRuleSets carries the rule sets associated with an
|
|
// account.
|
|
type AccountRuleSets struct {
|
|
Global RuleSet `json:"global"` // Required
|
|
}
|
|
|
|
// A RuleSet contains all the various push rules for an
|
|
// account. Listed in decreasing order of priority.
|
|
type RuleSet struct {
|
|
Override []*Rule `json:"override,omitempty"`
|
|
Content []*Rule `json:"content,omitempty"`
|
|
Room []*Rule `json:"room,omitempty"`
|
|
Sender []*Rule `json:"sender,omitempty"`
|
|
Underride []*Rule `json:"underride,omitempty"`
|
|
}
|
|
|
|
// A Rule contains matchers, conditions and final actions. While
|
|
// evaluating, at most one rule is considered matching.
|
|
//
|
|
// Kind and scope are part of the push rules request/responses, but
|
|
// not of the core data model.
|
|
type Rule struct {
|
|
// RuleID is either a free identifier, or the sender's MXID for
|
|
// SenderKind. Required.
|
|
RuleID string `json:"rule_id"`
|
|
|
|
// Default indicates whether this is a server-defined default, or
|
|
// a user-provided rule. Required.
|
|
//
|
|
// The server-default rules have the lowest priority.
|
|
Default bool `json:"default"`
|
|
|
|
// Enabled allows the user to disable rules while keeping them
|
|
// around. Required.
|
|
Enabled bool `json:"enabled"`
|
|
|
|
// Conditions provide the rule's conditions for OverrideKind and
|
|
// UnderrideKind. Not allowed for other kinds.
|
|
Conditions []*Condition `json:"conditions,omitempty"`
|
|
|
|
// Actions describe the desired outcome, should the rule
|
|
// match. Required.
|
|
Actions []*Action `json:"actions"`
|
|
|
|
// Pattern is the body pattern to match for ContentKind. Required
|
|
// for that kind. The interpretation is the same as that of
|
|
// Condition.Pattern.
|
|
Pattern *string `json:"pattern,omitempty"`
|
|
}
|
|
|
|
// Scope only has one valid value. See also AccountRuleSets.
|
|
type Scope string
|
|
|
|
const (
|
|
UnknownScope Scope = ""
|
|
GlobalScope Scope = "global"
|
|
)
|
|
|
|
// Kind is the type of push rule. See also RuleSet.
|
|
type Kind string
|
|
|
|
const (
|
|
UnknownKind Kind = ""
|
|
OverrideKind Kind = "override"
|
|
ContentKind Kind = "content"
|
|
RoomKind Kind = "room"
|
|
SenderKind Kind = "sender"
|
|
UnderrideKind Kind = "underride"
|
|
)
|