Fix MM53643 (#25683)
* Fix MM53643 * Add test * Remove unneeded part of a test --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1d879ed0f4
Коммит
539412b353
@@ -395,6 +395,40 @@ func TestSendNotifications_MentionsFollowers(t *testing.T) {
|
||||
assert.Nil(t, received2.GetBroadcast().BroadcastHooks)
|
||||
assert.Nil(t, received2.GetBroadcast().BroadcastHookArgs)
|
||||
})
|
||||
|
||||
t.Run("should sanitize the post if there is an error", func(t *testing.T) {
|
||||
messages, closeWS1 := connectFakeWebSocket(t, th, th.BasicUser.Id, "")
|
||||
defer closeWS1()
|
||||
|
||||
linkedPostId := "123456789"
|
||||
postURL := fmt.Sprintf("%s/%s/pl/%s", th.App.GetSiteURL(), th.BasicTeam.Name, linkedPostId)
|
||||
post := &model.Post{
|
||||
UserId: sender.Id,
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: postURL,
|
||||
Metadata: &model.PostMetadata{
|
||||
Embeds: []*model.PostEmbed{
|
||||
{
|
||||
Type: model.PostEmbedPermalink,
|
||||
URL: postURL,
|
||||
Data: &model.Post{},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
post.SetProps(model.StringInterface{model.PostPropsPreviewedPost: linkedPostId})
|
||||
|
||||
_, err := th.App.SendNotifications(th.Context, post, th.BasicTeam, th.BasicChannel, sender, nil, false)
|
||||
require.NoError(t, err)
|
||||
|
||||
received := <-messages
|
||||
require.Equal(t, model.WebsocketEventPosted, received.EventType())
|
||||
receivedPost := &model.Post{}
|
||||
err = json.Unmarshal([]byte(received.GetData()["post"].(string)), &receivedPost)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, postURL, receivedPost.Message)
|
||||
assert.Nil(t, receivedPost.Metadata.Embeds)
|
||||
})
|
||||
}
|
||||
|
||||
func assertUnmarshalsTo(t *testing.T, expected any, actual any) {
|
||||
|
||||
Ссылка в новой задаче
Block a user