Fix badge count for push notifications (#5672)

This commit is contained in:
enahum
2017-03-07 16:54:25 +00:00
committed by George Goldberg
parent 33b8b72a02
commit 2bea17251e
+7 -1
View File
@@ -1179,7 +1179,13 @@ func (us SqlUserStore) GetUnreadCount(userId string) StoreChannel {
go func() {
result := StoreResult{}
if count, err := us.GetReplica().SelectInt("SELECT SUM(CASE WHEN c.Type = 'D' THEN (c.TotalMsgCount - cm.MsgCount) ELSE cm.MentionCount END) FROM Channels c INNER JOIN ChannelMembers cm ON cm.ChannelId = c.Id AND cm.UserId = :UserId", map[string]interface{}{"UserId": userId}); err != nil {
if count, err := us.GetReplica().SelectInt(`
SELECT SUM(CASE WHEN c.Type = 'D' THEN (c.TotalMsgCount - cm.MsgCount) ELSE cm.MentionCount END)
FROM Channels c
INNER JOIN ChannelMembers cm
ON cm.ChannelId = c.Id
AND cm.UserId = :UserId
AND c.DeleteAt = 0`, map[string]interface{}{"UserId": userId}); err != nil {
result.Err = model.NewLocAppError("SqlUserStore.GetMentionCount", "store.sql_user.get_unread_count.app_error", nil, err.Error())
} else {
result.Data = count