summaryrefslogtreecommitdiffstats
path: root/app/channel.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-09-29 11:45:59 -0400
committerChristopher Speller <crspeller@gmail.com>2017-09-29 08:45:59 -0700
commit8b9dbb86133ff0fd6002a391268383d1593918ca (patch)
treeb8399f2bae881afe12f3bdb34ec725e97307144a /app/channel.go
parent5e50d3f4612dc8e6dffeff268f024a3d383a329c (diff)
downloadchat-8b9dbb86133ff0fd6002a391268383d1593918ca.tar.gz
chat-8b9dbb86133ff0fd6002a391268383d1593918ca.tar.bz2
chat-8b9dbb86133ff0fd6002a391268383d1593918ca.zip
PLT-7404 Return viewed at times in view channel API response (#7428)
* Return viewed at times in view channel API response * Updated transaction to read and write once * Remove transaction and only update if new value greater than older
Diffstat (limited to 'app/channel.go')
-rw-r--r--app/channel.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/app/channel.go b/app/channel.go
index 2d3709a0c..88f9cc7d7 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -1136,9 +1136,9 @@ func (a *App) SearchChannelsUserNotIn(teamId string, userId string, term string)
}
}
-func (a *App) ViewChannel(view *model.ChannelView, userId string, clearPushNotifications bool) *model.AppError {
+func (a *App) ViewChannel(view *model.ChannelView, userId string, clearPushNotifications bool) (map[string]int64, *model.AppError) {
if err := a.SetActiveChannel(userId, view.ChannelId); err != nil {
- return err
+ return nil, err
}
channelIds := []string{}
@@ -1157,14 +1157,14 @@ func (a *App) ViewChannel(view *model.ChannelView, userId string, clearPushNotif
}
if len(channelIds) == 0 {
- return nil
+ return map[string]int64{}, nil
}
uchan := a.Srv.Store.Channel().UpdateLastViewedAt(channelIds, userId)
if pchan != nil {
if result := <-pchan; result.Err != nil {
- return result.Err
+ return nil, result.Err
} else {
if result.Data.(int64) > 0 {
a.ClearPushNotification(userId, view.ChannelId)
@@ -1172,8 +1172,11 @@ func (a *App) ViewChannel(view *model.ChannelView, userId string, clearPushNotif
}
}
+ times := map[string]int64{}
if result := <-uchan; result.Err != nil {
- return result.Err
+ return nil, result.Err
+ } else {
+ times = result.Data.(map[string]int64)
}
if *utils.Cfg.ServiceSettings.EnableChannelViewedMessages && model.IsValidId(view.ChannelId) {
@@ -1182,7 +1185,7 @@ func (a *App) ViewChannel(view *model.ChannelView, userId string, clearPushNotif
go a.Publish(message)
}
- return nil
+ return times, nil
}
func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {