summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-08-18 18:45:35 -0400
committerCorey Hulen <corey@hulen.com>2016-08-18 14:45:35 -0800
commit9ad50d4d7562c1b029c888e892dd7cfc203f938a (patch)
tree0c173f204eb20e06a116762c2a378a742210c0db /store
parent3289c856130c4d1956dda9229fb3c6a060655b1a (diff)
downloadchat-9ad50d4d7562c1b029c888e892dd7cfc203f938a.tar.gz
chat-9ad50d4d7562c1b029c888e892dd7cfc203f938a.tar.bz2
chat-9ad50d4d7562c1b029c888e892dd7cfc203f938a.zip
Fixed calculation of mention count for direct channels (#3831)
* Fixed clientside calculation of direct channel mention count * Fixed serverside calculation of direct channel mention count
Diffstat (limited to 'store')
-rw-r--r--store/sql_user_store.go2
-rw-r--r--store/sql_user_store_test.go2
2 files changed, 3 insertions, 1 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 79d1d809a..e26183c1e 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -982,7 +982,7 @@ 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 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 {
+ 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 {
result.Err = model.NewLocAppError("SqlUserStore.GetMentionCount", "store.sql_user.get_unread_count.app_error", nil, err.Error())
} else {
result.Data = count
diff --git a/store/sql_user_store_test.go b/store/sql_user_store_test.go
index 4b722b0b3..e44cee99d 100644
--- a/store/sql_user_store_test.go
+++ b/store/sql_user_store_test.go
@@ -647,12 +647,14 @@ func TestUserUnreadCount(t *testing.T) {
p2.UserId = u1.Id
p2.Message = "first message"
Must(store.Post().Save(&p2))
+ Must(store.Channel().IncrementMentionCount(c2.Id, u2.Id))
p3 := model.Post{}
p3.ChannelId = c2.Id
p3.UserId = u1.Id
p3.Message = "second message"
Must(store.Post().Save(&p3))
+ Must(store.Channel().IncrementMentionCount(c2.Id, u2.Id))
badge := (<-store.User().GetUnreadCount(u2.Id)).Data.(int64)
if badge != 3 {