From cd88d718dd369335ee015756f95a514482126156 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Tue, 13 Jul 2021 08:41:42 +0530 Subject: [PATCH] MM-36894: Racy test: TestExecuteCommandInDirectMessageChannel (#17881) * MM-36894: Racy test: TestExecuteCommandInDirectMessageChannel We were using the pointer to the same post object in multiple push notifications because we were sending it in a loop of mentioned user list. To fix this, we clone the post every time. https://mattermost.atlassian.net/browse/MM-36894 ```release-note NONE ``` * Refactor markdown parsing ```release-note NONE ``` --- app/notification_push.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/notification_push.go b/app/notification_push.go index b69b52aeac..58d2c2bd45 100644 --- a/app/notification_push.go +++ b/app/notification_push.go @@ -56,12 +56,6 @@ type PushNotification struct { func (a *App) sendPushNotificationSync(post *model.Post, user *model.User, channel *model.Channel, channelName string, senderName string, explicitMention bool, channelWideMention bool, replyToThreadType string) *model.AppError { cfg := a.Config() - message, err := utils.StripMarkdown(post.Message) - if err != nil { - mlog.Warn("Failed parse to markdown", mlog.String("post_id", post.Id), mlog.Err(err)) - } else { - post.Message = message - } msg, appErr := a.BuildPushNotificationMessage( *cfg.EmailSettings.PushNotificationContents, post, @@ -585,6 +579,12 @@ func (a *App) buildFullPushNotificationMessage(contentsConfig string, post *mode } postMessage := post.Message + stripped, err := utils.StripMarkdown(postMessage) + if err != nil { + mlog.Warn("Failed parse to markdown", mlog.String("post_id", post.Id), mlog.Err(err)) + } else { + postMessage = stripped + } for _, attachment := range post.Attachments() { if attachment.Fallback != "" { postMessage += "\n" + attachment.Fallback