MM-20225: Fix notification badge count for All Activity (#13353)

When push notification setting was selected to "All Activity", we were
just sending the unread count for the channel from where the message was sent
and not for all channels.

After discussion with @enahum and @migbot, we decided to keep the badge count
to only refer to mentions and not unread posts.

Therefore, we only take the unread count for the user irrespective of the
notify_props settings.

Updated the tests to reflect that.

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2020-01-01 13:46:51 +05:30
коммит произвёл GitHub
родитель abfd8fcc02
Коммит f75c8c7c9f
2 изменённых файлов: 20 добавлений и 28 удалений

Просмотреть файл

@@ -453,11 +453,11 @@ func (a *App) BuildPushNotificationMessage(contentsConfig string, post *model.Po
msg = a.buildFullPushNotificationMessage(contentsConfig, post, user, channel, channelName, senderName, explicitMention, channelWideMention, replyToThreadType)
}
badge, err := a.getPushNotificationBadge(user, channel)
unreadCount, err := a.Srv.Store.User().GetUnreadCount(user.Id)
if err != nil {
return nil, err
}
msg.Badge = badge
msg.Badge = int(unreadCount)
return msg, nil
}
@@ -519,16 +519,3 @@ func (a *App) buildFullPushNotificationMessage(contentsConfig string, post *mode
return msg
}
func (a *App) getPushNotificationBadge(user *model.User, channel *model.Channel) (int, *model.AppError) {
var unreadCount int64
var err *model.AppError
if user.NotifyProps["push"] == "all" {
unreadCount, err = a.Srv.Store.User().GetAnyUnreadPostCountForChannel(user.Id, channel.Id)
} else {
unreadCount, err = a.Srv.Store.User().GetUnreadCount(user.Id)
}
return int(unreadCount), err
}