mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-20 08:40:14 +01:00
64472d9aab
This PR - adds tests for `evaluatePushrules` - removes the need for the UserAPI on the `OutputStreamEventConsumer` (for easier testing) - adds a method to get the pushrules from the database - adds a new default pushrule for `m.reaction` events (and some other tweaks)
143 lines
2.6 KiB
Go
143 lines
2.6 KiB
Go
package pushrules
|
|
|
|
const (
|
|
MRuleCall = ".m.rule.call"
|
|
MRuleEncryptedRoomOneToOne = ".m.rule.encrypted_room_one_to_one"
|
|
MRuleRoomOneToOne = ".m.rule.room_one_to_one"
|
|
MRuleMessage = ".m.rule.message"
|
|
MRuleEncrypted = ".m.rule.encrypted"
|
|
)
|
|
|
|
var defaultUnderrideRules = []*Rule{
|
|
&mRuleCallDefinition,
|
|
&mRuleRoomOneToOneDefinition,
|
|
&mRuleEncryptedRoomOneToOneDefinition,
|
|
&mRuleMessageDefinition,
|
|
&mRuleEncryptedDefinition,
|
|
}
|
|
|
|
var (
|
|
mRuleCallDefinition = Rule{
|
|
RuleID: MRuleCall,
|
|
Default: true,
|
|
Enabled: true,
|
|
Conditions: []*Condition{
|
|
{
|
|
Kind: EventMatchCondition,
|
|
Key: "type",
|
|
Pattern: "m.call.invite",
|
|
},
|
|
},
|
|
Actions: []*Action{
|
|
{Kind: NotifyAction},
|
|
{
|
|
Kind: SetTweakAction,
|
|
Tweak: SoundTweak,
|
|
Value: "ring",
|
|
},
|
|
{
|
|
Kind: SetTweakAction,
|
|
Tweak: HighlightTweak,
|
|
Value: false,
|
|
},
|
|
},
|
|
}
|
|
mRuleEncryptedRoomOneToOneDefinition = Rule{
|
|
RuleID: MRuleEncryptedRoomOneToOne,
|
|
Default: true,
|
|
Enabled: true,
|
|
Conditions: []*Condition{
|
|
{
|
|
Kind: RoomMemberCountCondition,
|
|
Is: "2",
|
|
},
|
|
{
|
|
Kind: EventMatchCondition,
|
|
Key: "type",
|
|
Pattern: "m.room.encrypted",
|
|
},
|
|
},
|
|
Actions: []*Action{
|
|
{Kind: NotifyAction},
|
|
{
|
|
Kind: SetTweakAction,
|
|
Tweak: SoundTweak,
|
|
Value: "default",
|
|
},
|
|
{
|
|
Kind: SetTweakAction,
|
|
Tweak: HighlightTweak,
|
|
Value: false,
|
|
},
|
|
},
|
|
}
|
|
mRuleRoomOneToOneDefinition = Rule{
|
|
RuleID: MRuleRoomOneToOne,
|
|
Default: true,
|
|
Enabled: true,
|
|
Conditions: []*Condition{
|
|
{
|
|
Kind: RoomMemberCountCondition,
|
|
Is: "2",
|
|
},
|
|
{
|
|
Kind: EventMatchCondition,
|
|
Key: "type",
|
|
Pattern: "m.room.message",
|
|
},
|
|
},
|
|
Actions: []*Action{
|
|
{Kind: NotifyAction},
|
|
{
|
|
Kind: SetTweakAction,
|
|
Tweak: HighlightTweak,
|
|
Value: false,
|
|
},
|
|
{
|
|
Kind: SetTweakAction,
|
|
Tweak: HighlightTweak,
|
|
Value: false,
|
|
},
|
|
},
|
|
}
|
|
mRuleMessageDefinition = Rule{
|
|
RuleID: MRuleMessage,
|
|
Default: true,
|
|
Enabled: true,
|
|
Conditions: []*Condition{
|
|
{
|
|
Kind: EventMatchCondition,
|
|
Key: "type",
|
|
Pattern: "m.room.message",
|
|
},
|
|
},
|
|
Actions: []*Action{
|
|
{Kind: NotifyAction},
|
|
{
|
|
Kind: SetTweakAction,
|
|
Tweak: HighlightTweak,
|
|
Value: false,
|
|
},
|
|
},
|
|
}
|
|
mRuleEncryptedDefinition = Rule{
|
|
RuleID: MRuleEncrypted,
|
|
Default: true,
|
|
Enabled: true,
|
|
Conditions: []*Condition{
|
|
{
|
|
Kind: EventMatchCondition,
|
|
Key: "type",
|
|
Pattern: "m.room.encrypted",
|
|
},
|
|
},
|
|
Actions: []*Action{
|
|
{Kind: NotifyAction},
|
|
{
|
|
Kind: SetTweakAction,
|
|
Tweak: HighlightTweak,
|
|
Value: false,
|
|
},
|
|
},
|
|
}
|
|
)
|