diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-09-26 16:34:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-26 16:34:12 +0200 |
commit | 15d64fb201848002a25facc3bbffc9535a704df6 (patch) | |
tree | 558282bb4126eef469525c3cb11ea3238919e6fa /app/post.go | |
parent | 37e00ef916af9a5aeae760a01fa0a0cf8ca93637 (diff) | |
download | chat-15d64fb201848002a25facc3bbffc9535a704df6.tar.gz chat-15d64fb201848002a25facc3bbffc9535a704df6.tar.bz2 chat-15d64fb201848002a25facc3bbffc9535a704df6.zip |
MM-7188: Cleaning push notification on every read, not only on channel switch (#9348)
* MM-7188: Cleaning push notification on every read, not only on channel switch
* Removed unnecesary goroutine
* Fixing tests
* Applying suggestion from PR
Diffstat (limited to 'app/post.go')
-rw-r--r-- | app/post.go | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/app/post.go b/app/post.go index 1daad6eea..fc941a68f 100644 --- a/app/post.go +++ b/app/post.go @@ -24,7 +24,7 @@ import ( "golang.org/x/net/html/charset" ) -func (a *App) CreatePostAsUser(post *model.Post) (*model.Post, *model.AppError) { +func (a *App) CreatePostAsUser(post *model.Post, clearPushNotifications bool) (*model.Post, *model.AppError) { // Check that channel has not been deleted var channel *model.Channel if result := <-a.Srv.Store.Channel().Get(post.ChannelId, true); result.Err != nil { @@ -78,14 +78,8 @@ func (a *App) CreatePostAsUser(post *model.Post) (*model.Post, *model.AppError) } else { // Update the LastViewAt only if the post does not have from_webhook prop set (eg. Zapier app) if _, ok := post.Props["from_webhook"]; !ok { - if result := <-a.Srv.Store.Channel().UpdateLastViewedAt([]string{post.ChannelId}, post.UserId); result.Err != nil { - mlog.Error(fmt.Sprintf("Encountered error updating last viewed, channel_id=%s, user_id=%s, err=%v", post.ChannelId, post.UserId, result.Err)) - } - - if *a.Config().ServiceSettings.EnableChannelViewedMessages { - message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, "", "", post.UserId, nil) - message.Add("channel_id", post.ChannelId) - a.Publish(message) + if _, err := a.MarkChannelsAsViewed([]string{post.ChannelId}, post.UserId, clearPushNotifications); err != nil { + mlog.Error(fmt.Sprintf("Encountered error updating last viewed, channel_id=%s, user_id=%s, err=%v", post.ChannelId, post.UserId, err)) } } |