diff --git a/internal/pushrules/action.go b/internal/pushrules/action.go index 15fa3e89f..c7b8cec83 100644 --- a/internal/pushrules/action.go +++ b/internal/pushrules/action.go @@ -16,7 +16,7 @@ type Action struct { Tweak TweakKey `json:"-"` // 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) { diff --git a/internal/pushrules/default_content.go b/internal/pushrules/default_content.go index ce78194c3..158afd18b 100644 --- a/internal/pushrules/default_content.go +++ b/internal/pushrules/default_content.go @@ -26,6 +26,7 @@ func mRuleContainsUserNameDefinition(localpart string) *Rule { { Kind: SetTweakAction, Tweak: HighlightTweak, + Value: true, }, }, } diff --git a/internal/pushrules/default_override.go b/internal/pushrules/default_override.go index 1901445b8..6f66fd66a 100644 --- a/internal/pushrules/default_override.go +++ b/internal/pushrules/default_override.go @@ -71,6 +71,7 @@ var ( { Kind: SetTweakAction, Tweak: HighlightTweak, + Value: true, }, }, } @@ -95,6 +96,7 @@ var ( { Kind: SetTweakAction, Tweak: HighlightTweak, + Value: false, }, }, } @@ -118,6 +120,7 @@ var ( { Kind: SetTweakAction, Tweak: HighlightTweak, + Value: false, }, }, } @@ -155,6 +158,7 @@ func mRuleInviteForMeDefinition(userID string) *Rule { { Kind: SetTweakAction, Tweak: HighlightTweak, + Value: false, }, }, } diff --git a/internal/pushrules/default_underride.go b/internal/pushrules/default_underride.go index 0f5bc3e1f..fa09214ed 100644 --- a/internal/pushrules/default_underride.go +++ b/internal/pushrules/default_underride.go @@ -35,6 +35,11 @@ var ( Tweak: SoundTweak, Value: "ring", }, + { + Kind: SetTweakAction, + Tweak: HighlightTweak, + Value: false, + }, }, } mRuleEncryptedRoomOneToOneDefinition = Rule{ @@ -56,8 +61,8 @@ var ( {Kind: NotifyAction}, { Kind: SetTweakAction, - Tweak: SoundTweak, - Value: "default", + Tweak: HighlightTweak, + Value: false, }, }, } @@ -80,8 +85,8 @@ var ( {Kind: NotifyAction}, { Kind: SetTweakAction, - Tweak: SoundTweak, - Value: "default", + Tweak: HighlightTweak, + Value: false, }, }, } @@ -96,7 +101,7 @@ var ( Pattern: "m.room.message", }, }, - Actions: []*Action{{Kind: NotifyAction}}, + Actions: []*Action{{Kind: DontNotifyAction}}, } mRuleEncryptedDefinition = Rule{ RuleID: MRuleEncrypted, @@ -109,6 +114,6 @@ var ( Pattern: "m.room.encrypted", }, }, - Actions: []*Action{{Kind: NotifyAction}}, + Actions: []*Action{{Kind: DontNotifyAction}}, } ) diff --git a/internal/pushrules/pushrules.go b/internal/pushrules/pushrules.go index 358065ab6..bbed1f95f 100644 --- a/internal/pushrules/pushrules.go +++ b/internal/pushrules/pushrules.go @@ -42,12 +42,12 @@ type Rule struct { // Conditions provide the rule's conditions for OverrideKind and // 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 // for that kind. The interpretation is the same as that of // Condition.Pattern. - Pattern string `json:"pattern,omitempty"` + Pattern string `json:"pattern"` } // Scope only has one valid value. See also AccountRuleSets. diff --git a/userapi/internal/api.go b/userapi/internal/api.go index 394d30dcf..7a42fc605 100644 --- a/userapi/internal/api.go +++ b/userapi/internal/api.go @@ -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 { return fmt.Errorf("failed to save default push rules: %w", err) } + res.RuleSets = pushRuleSets + return nil } var data pushrules.AccountRuleSets if err := json.Unmarshal([]byte(bs), &data); err != nil {