From 30a6ddc995a76b0af6fff1e45bbfca80910f1cb6 Mon Sep 17 00:00:00 2001 From: M-ZubairAhmed Date: Fri, 8 Nov 2024 12:21:27 +0000 Subject: [PATCH] [MM-61439] New Users: Change default setting for mobile push notifications to 'online, away, or offline'(#29142) --- server/public/model/user.go | 2 +- server/public/model/user_test.go | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/server/public/model/user.go b/server/public/model/user.go index 4bbe1808d3..7b7c6b7021 100644 --- a/server/public/model/user.go +++ b/server/public/model/user.go @@ -567,7 +567,7 @@ func (u *User) SetDefaultNotifications() { u.NotifyProps[DesktopSoundNotifyProp] = "true" u.NotifyProps[MentionKeysNotifyProp] = "" u.NotifyProps[ChannelMentionsNotifyProp] = "true" - u.NotifyProps[PushStatusNotifyProp] = StatusAway + u.NotifyProps[PushStatusNotifyProp] = StatusOnline u.NotifyProps[CommentsNotifyProp] = CommentsNotifyNever u.NotifyProps[FirstNameNotifyProp] = "false" u.NotifyProps[DesktopThreadsNotifyProp] = UserNotifyAll diff --git a/server/public/model/user_test.go b/server/public/model/user_test.go index b870a7018c..17af85f03d 100644 --- a/server/public/model/user_test.go +++ b/server/public/model/user_test.go @@ -204,6 +204,17 @@ func TestUserPreSave(t *testing.T) { user.Etag(true, true) assert.NotNil(t, user.Timezone, "Timezone is nil") assert.Equal(t, user.Timezone["useAutomaticTimezone"], "true", "Timezone is not set to default") + + // Set default user with notify props + userWithDefaultNotifyProps := User{} + userWithDefaultNotifyProps.SetDefaultNotifications() + + for notifyPropKey, expectedNotifyPropValue := range userWithDefaultNotifyProps.NotifyProps { + actualNotifyPropValue, ok := user.NotifyProps[notifyPropKey] + + assert.True(t, ok, "Notify prop %s is not set", notifyPropKey) + assert.Equal(t, expectedNotifyPropValue, actualNotifyPropValue, "Notify prop %s is not set to default", notifyPropKey) + } } func TestUserPreSavePwdTooLong(t *testing.T) { @@ -215,6 +226,17 @@ func TestUserPreSavePwdTooLong(t *testing.T) { func TestUserPreUpdate(t *testing.T) { user := User{Password: "test"} user.PreUpdate() + + // Set default user with notify props + userWithDefaultNotifyProps := User{} + userWithDefaultNotifyProps.SetDefaultNotifications() + + for notifyPropKey, expectedNotifyPropValue := range userWithDefaultNotifyProps.NotifyProps { + actualNotifyPropValue, ok := user.NotifyProps[notifyPropKey] + + assert.True(t, ok, "Notify prop %s is not set", notifyPropKey) + assert.Equal(t, expectedNotifyPropValue, actualNotifyPropValue, "Notify prop %s is not set to default", notifyPropKey) + } } func TestUserUpdateMentionKeysFromUsername(t *testing.T) {