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
```
Этот коммит содержится в:
Agniva De Sarker
2021-07-13 08:41:42 +05:30
коммит произвёл GitHub
родитель 347af1c612
Коммит cd88d718dd

Просмотреть файл

@@ -56,12 +56,6 @@ type PushNotification struct {
func (a *App) sendPushNotificationSync(post *model.Post, user *model.User, channel *model.Channel, channelName string, senderName string, 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 { explicitMention bool, channelWideMention bool, replyToThreadType string) *model.AppError {
cfg := a.Config() 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( msg, appErr := a.BuildPushNotificationMessage(
*cfg.EmailSettings.PushNotificationContents, *cfg.EmailSettings.PushNotificationContents,
post, post,
@@ -585,6 +579,12 @@ func (a *App) buildFullPushNotificationMessage(contentsConfig string, post *mode
} }
postMessage := post.Message 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() { for _, attachment := range post.Attachments() {
if attachment.Fallback != "" { if attachment.Fallback != "" {
postMessage += "\n" + attachment.Fallback postMessage += "\n" + attachment.Fallback