From 15d64fb201848002a25facc3bbffc9535a704df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Wed, 26 Sep 2018 16:34:12 +0200 Subject: 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 --- app/post.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'app/post.go') 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)) } } -- cgit v1.2.3-1-g7c22