2022-03-03 05:40:53 -06:00
|
|
|
package pushrules
|
|
|
|
|
|
|
|
func defaultOverrideRules(userID string) []*Rule {
|
|
|
|
return []*Rule{
|
|
|
|
&mRuleMasterDefinition,
|
|
|
|
&mRuleSuppressNoticesDefinition,
|
|
|
|
mRuleInviteForMeDefinition(userID),
|
|
|
|
&mRuleMemberEventDefinition,
|
|
|
|
&mRuleContainsDisplayNameDefinition,
|
|
|
|
&mRuleRoomNotifDefinition,
|
2022-09-09 06:56:33 -05:00
|
|
|
&mRuleTombstoneDefinition,
|
|
|
|
&mRuleReactionDefinition,
|
2023-10-24 04:51:08 -05:00
|
|
|
&mRuleACLsDefinition,
|
2022-03-03 05:40:53 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
MRuleMaster = ".m.rule.master"
|
|
|
|
MRuleSuppressNotices = ".m.rule.suppress_notices"
|
|
|
|
MRuleInviteForMe = ".m.rule.invite_for_me"
|
|
|
|
MRuleMemberEvent = ".m.rule.member_event"
|
|
|
|
MRuleContainsDisplayName = ".m.rule.contains_display_name"
|
|
|
|
MRuleTombstone = ".m.rule.tombstone"
|
|
|
|
MRuleRoomNotif = ".m.rule.roomnotif"
|
2022-09-09 06:56:33 -05:00
|
|
|
MRuleReaction = ".m.rule.reaction"
|
2022-12-23 05:52:47 -06:00
|
|
|
MRuleRoomACLs = ".m.rule.room.server_acl"
|
2022-03-03 05:40:53 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
mRuleMasterDefinition = Rule{
|
2022-12-23 05:52:47 -06:00
|
|
|
RuleID: MRuleMaster,
|
|
|
|
Default: true,
|
|
|
|
Enabled: false,
|
2023-10-24 04:51:08 -05:00
|
|
|
Actions: []*Action{},
|
2022-03-03 05:40:53 -06:00
|
|
|
}
|
|
|
|
mRuleSuppressNoticesDefinition = Rule{
|
|
|
|
RuleID: MRuleSuppressNotices,
|
|
|
|
Default: true,
|
|
|
|
Enabled: true,
|
|
|
|
Conditions: []*Condition{
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "content.msgtype",
|
2022-12-23 05:52:47 -06:00
|
|
|
Pattern: pointer("m.notice"),
|
2022-03-03 05:40:53 -06:00
|
|
|
},
|
|
|
|
},
|
2023-10-24 04:51:08 -05:00
|
|
|
Actions: []*Action{},
|
2022-03-03 05:40:53 -06:00
|
|
|
}
|
|
|
|
mRuleMemberEventDefinition = Rule{
|
|
|
|
RuleID: MRuleMemberEvent,
|
|
|
|
Default: true,
|
|
|
|
Enabled: true,
|
|
|
|
Conditions: []*Condition{
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "type",
|
2022-12-23 05:52:47 -06:00
|
|
|
Pattern: pointer("m.room.member"),
|
2022-03-03 05:40:53 -06:00
|
|
|
},
|
|
|
|
},
|
2023-10-24 04:51:08 -05:00
|
|
|
Actions: []*Action{},
|
2022-03-03 05:40:53 -06:00
|
|
|
}
|
|
|
|
mRuleContainsDisplayNameDefinition = Rule{
|
|
|
|
RuleID: MRuleContainsDisplayName,
|
|
|
|
Default: true,
|
|
|
|
Enabled: true,
|
|
|
|
Conditions: []*Condition{{Kind: ContainsDisplayNameCondition}},
|
|
|
|
Actions: []*Action{
|
|
|
|
{Kind: NotifyAction},
|
|
|
|
{
|
|
|
|
Kind: SetTweakAction,
|
|
|
|
Tweak: SoundTweak,
|
|
|
|
Value: "default",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Kind: SetTweakAction,
|
|
|
|
Tweak: HighlightTweak,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
mRuleTombstoneDefinition = Rule{
|
|
|
|
RuleID: MRuleTombstone,
|
|
|
|
Default: true,
|
|
|
|
Enabled: true,
|
|
|
|
Conditions: []*Condition{
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "type",
|
2022-12-23 05:52:47 -06:00
|
|
|
Pattern: pointer("m.room.tombstone"),
|
2022-03-03 05:40:53 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "state_key",
|
2022-12-23 05:52:47 -06:00
|
|
|
Pattern: pointer(""),
|
2022-03-03 05:40:53 -06:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Actions: []*Action{
|
|
|
|
{Kind: NotifyAction},
|
|
|
|
{
|
|
|
|
Kind: SetTweakAction,
|
|
|
|
Tweak: HighlightTweak,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2022-12-23 05:52:47 -06:00
|
|
|
mRuleACLsDefinition = Rule{
|
|
|
|
RuleID: MRuleRoomACLs,
|
|
|
|
Default: true,
|
|
|
|
Enabled: true,
|
|
|
|
Conditions: []*Condition{
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "type",
|
|
|
|
Pattern: pointer("m.room.server_acl"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "state_key",
|
|
|
|
Pattern: pointer(""),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Actions: []*Action{},
|
|
|
|
}
|
2022-03-03 05:40:53 -06:00
|
|
|
mRuleRoomNotifDefinition = Rule{
|
|
|
|
RuleID: MRuleRoomNotif,
|
|
|
|
Default: true,
|
|
|
|
Enabled: true,
|
|
|
|
Conditions: []*Condition{
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "content.body",
|
2022-12-23 05:52:47 -06:00
|
|
|
Pattern: pointer("@room"),
|
2022-03-03 05:40:53 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Kind: SenderNotificationPermissionCondition,
|
|
|
|
Key: "room",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Actions: []*Action{
|
|
|
|
{Kind: NotifyAction},
|
|
|
|
{
|
|
|
|
Kind: SetTweakAction,
|
|
|
|
Tweak: HighlightTweak,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2022-09-09 06:56:33 -05:00
|
|
|
mRuleReactionDefinition = Rule{
|
|
|
|
RuleID: MRuleReaction,
|
|
|
|
Default: true,
|
|
|
|
Enabled: true,
|
|
|
|
Conditions: []*Condition{
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "type",
|
2022-12-23 05:52:47 -06:00
|
|
|
Pattern: pointer("m.reaction"),
|
2022-09-09 06:56:33 -05:00
|
|
|
},
|
|
|
|
},
|
2023-10-24 04:51:08 -05:00
|
|
|
Actions: []*Action{},
|
2022-09-09 06:56:33 -05:00
|
|
|
}
|
2022-03-03 05:40:53 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func mRuleInviteForMeDefinition(userID string) *Rule {
|
|
|
|
return &Rule{
|
|
|
|
RuleID: MRuleInviteForMe,
|
|
|
|
Default: true,
|
|
|
|
Enabled: true,
|
|
|
|
Conditions: []*Condition{
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "type",
|
2022-12-23 05:52:47 -06:00
|
|
|
Pattern: pointer("m.room.member"),
|
2022-03-03 05:40:53 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "content.membership",
|
2022-12-23 05:52:47 -06:00
|
|
|
Pattern: pointer("invite"),
|
2022-03-03 05:40:53 -06:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Kind: EventMatchCondition,
|
|
|
|
Key: "state_key",
|
2022-12-23 05:52:47 -06:00
|
|
|
Pattern: pointer(userID),
|
2022-03-03 05:40:53 -06:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Actions: []*Action{
|
|
|
|
{Kind: NotifyAction},
|
|
|
|
{
|
|
|
|
Kind: SetTweakAction,
|
|
|
|
Tweak: SoundTweak,
|
|
|
|
Value: "default",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|