From 1f5c8c4e4ebb2e163278f3e62d640f41a2df7294 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Fri, 11 Mar 2016 00:14:55 -0300 Subject: Option to enable full snippets in push notifications --- store/sql_user_store.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'store/sql_user_store.go') diff --git a/store/sql_user_store.go b/store/sql_user_store.go index cc6829b94..6062b8a6a 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -652,3 +652,22 @@ func (us SqlUserStore) AnalyticsUniqueUserCount(teamId string) StoreChannel { return storeChannel } + +func (us SqlUserStore) GetUnreadCount(userId string) StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + if count, err := us.GetReplica().SelectInt("SELECT SUM(CASE WHEN c.Type = 'D' THEN (c.TotalMsgCount - cm.MsgCount) ELSE 0 END + cm.MentionCount) FROM Channels c INNER JOIN ChannelMembers cm ON cm.ChannelId = c.Id AND cm.UserId = :UserId", 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 + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} -- cgit v1.2.3-1-g7c22