From fa1f2a85049daca1657b268530fc98c110e3b8da Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Mon, 14 Dec 2020 14:24:12 +0530 Subject: [PATCH] MM-31323: Fix racy test TestHandleCommandResponsePost (#16542) In https://github.com/mattermost/mattermost-server/pull/16089, we added logic to modify the notification text in the presence of fallback text. Unfortunately, that created a race condition during publishing the post via websockets. To fix this, we create a clone of the post before sending it off for push notifications. https://mattermost.atlassian.net/browse/MM-31323 ```release-note NONE ``` --- app/notification.go | 2 +- app/notification_push.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/notification.go b/app/notification.go index e2567bee40..65a093ee66 100644 --- a/app/notification.go +++ b/app/notification.go @@ -210,7 +210,7 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod } notification := &PostNotification{ - Post: post, + Post: post.Clone(), Channel: channel, ProfileMap: profileMap, Sender: sender, diff --git a/app/notification_push.go b/app/notification_push.go index 83fe0b9770..c8ef59d8f1 100644 --- a/app/notification_push.go +++ b/app/notification_push.go @@ -583,7 +583,9 @@ func (a *App) buildFullPushNotificationMessage(contentsConfig string, post *mode } for _, attachment := range post.Attachments() { - post.Message += "\n" + attachment.Fallback + if attachment.Fallback != "" { + post.Message += "\n" + attachment.Fallback + } } userLocale := utils.GetUserTranslations(user.Locale)