summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorsamogot <samogot@gmail.com>2016-07-14 15:19:27 +0300
committerJoram Wilander <jwawilander@gmail.com>2016-07-14 08:19:27 -0400
commit9b9facd3d21a7ab341dd6d80fd8b53fb852ae036 (patch)
tree11418f04ce57bb6083797c29ceba690b97302e15 /store
parent6abc9601bec18e5005ff16dd4147bf038dafb264 (diff)
downloadchat-9b9facd3d21a7ab341dd6d80fd8b53fb852ae036.tar.gz
chat-9b9facd3d21a7ab341dd6d80fd8b53fb852ae036.tar.bz2
chat-9b9facd3d21a7ab341dd6d80fd8b53fb852ae036.zip
PLT-3366 Holding down the ALT key and clicking on a message adds a new messages indicator (squashed) (#3374)
Diffstat (limited to 'store')
-rw-r--r--store/sql_channel_store.go52
-rw-r--r--store/store.go1
2 files changed, 53 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index e5e0aa8ba..2b356d0de 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -856,6 +856,58 @@ func (s SqlChannelStore) CheckOpenChannelPermissions(teamId string, channelId st
return storeChannel
}
+func (s SqlChannelStore) SetLastViewedAt(channelId string, userId string, newLastViewedAt int64) StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ var query string
+
+ if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_POSTGRES {
+ query = `UPDATE
+ ChannelMembers
+ SET
+ MentionCount = 0,
+ MsgCount = Channels.TotalMsgCount - (SELECT COUNT(*)
+ FROM Posts
+ WHERE ChannelId = :ChannelId
+ AND CreateAt > :NewLastViewedAt),
+ LastViewedAt = :NewLastViewedAt
+ FROM
+ Channels
+ WHERE
+ Channels.Id = ChannelMembers.ChannelId
+ AND UserId = :UserId
+ AND ChannelId = :ChannelId`
+ } else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
+ query = `UPDATE
+ ChannelMembers, Channels
+ SET
+ ChannelMembers.MentionCount = 0,
+ ChannelMembers.MsgCount = Channels.TotalMsgCount - (SELECT COUNT(*)
+ FROM Posts
+ WHERE ChannelId = :ChannelId
+ AND CreateAt > :NewLastViewedAt),
+ ChannelMembers.LastViewedAt = :NewLastViewedAt
+ WHERE
+ Channels.Id = ChannelMembers.ChannelId
+ AND UserId = :UserId
+ AND ChannelId = :ChannelId`
+ }
+
+ _, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId, "UserId": userId, "NewLastViewedAt": newLastViewedAt})
+ if err != nil {
+ result.Err = model.NewLocAppError("SqlChannelStore.SetLastViewedAt", "store.sql_channel.set_last_viewed_at.app_error", nil, "channel_id="+channelId+", user_id="+userId+", "+err.Error())
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
diff --git a/store/store.go b/store/store.go
index f576cc2ab..445de440a 100644
--- a/store/store.go
+++ b/store/store.go
@@ -99,6 +99,7 @@ type ChannelStore interface {
CheckOpenChannelPermissions(teamId string, channelId string) StoreChannel
CheckPermissionsToByName(teamId string, channelName string, userId string) StoreChannel
UpdateLastViewedAt(channelId string, userId string) StoreChannel
+ SetLastViewedAt(channelId string, userId string, newLastViewedAt int64) StoreChannel
IncrementMentionCount(channelId string, userId string) StoreChannel
AnalyticsTypeCount(teamId string, channelType string) StoreChannel
ExtraUpdateByUser(userId string, time int64) StoreChannel