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) {