summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store.go
diff options
context:
space:
mode:
authorElias Nahum <nahumhbl@gmail.com>2016-03-11 00:14:55 -0300
committerElias Nahum <nahumhbl@gmail.com>2016-03-17 13:20:17 -0300
commit1f5c8c4e4ebb2e163278f3e62d640f41a2df7294 (patch)
treea659674c9980e23752fc8d9f07eb48014c8bce26 /store/sql_user_store.go
parentd383ed2f8dfc320c090b67d9f2e2d111710ca3cf (diff)
downloadchat-1f5c8c4e4ebb2e163278f3e62d640f41a2df7294.tar.gz
chat-1f5c8c4e4ebb2e163278f3e62d640f41a2df7294.tar.bz2
chat-1f5c8c4e4ebb2e163278f3e62d640f41a2df7294.zip
Option to enable full snippets in push notifications
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r--store/sql_user_store.go19
1 files changed, 19 insertions, 0 deletions
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
+}