Update defaults

This commit is contained in:
Neil Alexander 2022-02-21 09:52:34 +00:00
parent 4ce5fece5b
commit 1aa25b38da
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
6 changed files with 21 additions and 9 deletions

View file

@ -16,7 +16,7 @@ type Action struct {
Tweak TweakKey `json:"-"` Tweak TweakKey `json:"-"`
// Value is some value interpreted according to Kind and Tweak. // Value is some value interpreted according to Kind and Tweak.
Value interface{} `json:"value,omitempty"` Value interface{} `json:"value"`
} }
func (a *Action) MarshalJSON() ([]byte, error) { func (a *Action) MarshalJSON() ([]byte, error) {

View file

@ -26,6 +26,7 @@ func mRuleContainsUserNameDefinition(localpart string) *Rule {
{ {
Kind: SetTweakAction, Kind: SetTweakAction,
Tweak: HighlightTweak, Tweak: HighlightTweak,
Value: true,
}, },
}, },
} }

View file

@ -71,6 +71,7 @@ var (
{ {
Kind: SetTweakAction, Kind: SetTweakAction,
Tweak: HighlightTweak, Tweak: HighlightTweak,
Value: true,
}, },
}, },
} }
@ -95,6 +96,7 @@ var (
{ {
Kind: SetTweakAction, Kind: SetTweakAction,
Tweak: HighlightTweak, Tweak: HighlightTweak,
Value: false,
}, },
}, },
} }
@ -118,6 +120,7 @@ var (
{ {
Kind: SetTweakAction, Kind: SetTweakAction,
Tweak: HighlightTweak, Tweak: HighlightTweak,
Value: false,
}, },
}, },
} }
@ -155,6 +158,7 @@ func mRuleInviteForMeDefinition(userID string) *Rule {
{ {
Kind: SetTweakAction, Kind: SetTweakAction,
Tweak: HighlightTweak, Tweak: HighlightTweak,
Value: false,
}, },
}, },
} }

View file

@ -35,6 +35,11 @@ var (
Tweak: SoundTweak, Tweak: SoundTweak,
Value: "ring", Value: "ring",
}, },
{
Kind: SetTweakAction,
Tweak: HighlightTweak,
Value: false,
},
}, },
} }
mRuleEncryptedRoomOneToOneDefinition = Rule{ mRuleEncryptedRoomOneToOneDefinition = Rule{
@ -56,8 +61,8 @@ var (
{Kind: NotifyAction}, {Kind: NotifyAction},
{ {
Kind: SetTweakAction, Kind: SetTweakAction,
Tweak: SoundTweak, Tweak: HighlightTweak,
Value: "default", Value: false,
}, },
}, },
} }
@ -80,8 +85,8 @@ var (
{Kind: NotifyAction}, {Kind: NotifyAction},
{ {
Kind: SetTweakAction, Kind: SetTweakAction,
Tweak: SoundTweak, Tweak: HighlightTweak,
Value: "default", Value: false,
}, },
}, },
} }
@ -96,7 +101,7 @@ var (
Pattern: "m.room.message", Pattern: "m.room.message",
}, },
}, },
Actions: []*Action{{Kind: NotifyAction}}, Actions: []*Action{{Kind: DontNotifyAction}},
} }
mRuleEncryptedDefinition = Rule{ mRuleEncryptedDefinition = Rule{
RuleID: MRuleEncrypted, RuleID: MRuleEncrypted,
@ -109,6 +114,6 @@ var (
Pattern: "m.room.encrypted", Pattern: "m.room.encrypted",
}, },
}, },
Actions: []*Action{{Kind: NotifyAction}}, Actions: []*Action{{Kind: DontNotifyAction}},
} }
) )

View file

@ -42,12 +42,12 @@ type Rule struct {
// Conditions provide the rule's conditions for OverrideKind and // Conditions provide the rule's conditions for OverrideKind and
// UnderrideKind. Not allowed for other kinds. // UnderrideKind. Not allowed for other kinds.
Conditions []*Condition `json:"conditions,omitempty"` Conditions []*Condition `json:"conditions"`
// Pattern is the body pattern to match for ContentKind. Required // Pattern is the body pattern to match for ContentKind. Required
// for that kind. The interpretation is the same as that of // for that kind. The interpretation is the same as that of
// Condition.Pattern. // Condition.Pattern.
Pattern string `json:"pattern,omitempty"` Pattern string `json:"pattern"`
} }
// Scope only has one valid value. See also AccountRuleSets. // Scope only has one valid value. See also AccountRuleSets.

View file

@ -749,6 +749,8 @@ func (a *UserInternalAPI) QueryPushRules(ctx context.Context, req *api.QueryPush
if err := a.DB.SaveAccountData(ctx, localpart, "", pushRulesAccountDataType, json.RawMessage(prbs)); err != nil { if err := a.DB.SaveAccountData(ctx, localpart, "", pushRulesAccountDataType, json.RawMessage(prbs)); err != nil {
return fmt.Errorf("failed to save default push rules: %w", err) return fmt.Errorf("failed to save default push rules: %w", err)
} }
res.RuleSets = pushRuleSets
return nil
} }
var data pushrules.AccountRuleSets var data pushrules.AccountRuleSets
if err := json.Unmarshal([]byte(bs), &data); err != nil { if err := json.Unmarshal([]byte(bs), &data); err != nil {