MM-15035: Read from file infos from master on post creation (#10899)
* MM-15035: Read from file infos from master on post creation * Handling edit post cases for get files metadata
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e59674cfdd
Коммит
87ff64ea6d
@@ -83,7 +83,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
Message: message,
|
||||
}
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
t.Run("doesn't mutate provided post", func(t *testing.T) {
|
||||
assert.NotEqual(t, clientPost, post, "should've returned a new post")
|
||||
@@ -109,7 +109,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
|
||||
post := th.CreatePost(th.BasicChannel)
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
assert.False(t, clientPost == post, "should've returned a new post")
|
||||
assert.Equal(t, clientPost, post, "shouldn't have changed any metadata")
|
||||
@@ -125,7 +125,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
reaction3 := th.AddReactionToPost(post, th.BasicUser2, "ice_cream")
|
||||
post.HasReactions = true
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
assert.Len(t, clientPost.Metadata.Reactions, 3, "should've populated Reactions")
|
||||
assert.Equal(t, reaction1, clientPost.Metadata.Reactions[0], "first reaction is incorrect")
|
||||
@@ -149,7 +149,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
|
||||
fileInfo.PostId = post.Id
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
assert.Equal(t, []*model.FileInfo{fileInfo}, clientPost.Metadata.Files, "should've populated Files")
|
||||
})
|
||||
@@ -183,7 +183,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
th.AddReactionToPost(post, th.BasicUser2, "angry")
|
||||
post.HasReactions = true
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
t.Run("populates emojis", func(t *testing.T) {
|
||||
assert.ElementsMatch(t, []*model.Emoji{}, clientPost.Metadata.Emojis, "should've populated empty Emojis")
|
||||
@@ -228,7 +228,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
th.AddReactionToPost(post, th.BasicUser2, "angry")
|
||||
post.HasReactions = true
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
t.Run("pupulates emojis", func(t *testing.T) {
|
||||
assert.ElementsMatch(t, []*model.Emoji{emoji1, emoji2, emoji3, emoji4}, clientPost.Metadata.Emojis, "should've populated post.Emojis")
|
||||
@@ -251,7 +251,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
}, th.BasicChannel, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
t.Run("populates image dimensions", func(t *testing.T) {
|
||||
imageDimensions := clientPost.Metadata.Images
|
||||
@@ -295,7 +295,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
}, th.BasicChannel, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
// Reminder that only the first link gets an embed and dimensions
|
||||
|
||||
@@ -330,7 +330,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
}, th.BasicChannel, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
t.Run("populates embeds", func(t *testing.T) {
|
||||
assert.ElementsMatch(t, []*model.PostEmbed{
|
||||
@@ -381,7 +381,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
}, th.BasicChannel, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
t.Run("populates embeds", func(t *testing.T) {
|
||||
assert.ElementsMatch(t, []*model.PostEmbed{
|
||||
@@ -411,7 +411,7 @@ func TestPreparePostForClient(t *testing.T) {
|
||||
})
|
||||
|
||||
post := th.CreatePost(th.BasicChannel)
|
||||
post = th.App.PreparePostForClient(post, false)
|
||||
post = th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
assert.Nil(t, post.Metadata)
|
||||
|
||||
@@ -464,7 +464,7 @@ func testProxyLinkedImage(t *testing.T, th *TestHelper, shouldProxy bool) {
|
||||
Message: fmt.Sprintf(postTemplate, imageURL),
|
||||
}
|
||||
|
||||
clientPost := th.App.PreparePostForClient(post, false)
|
||||
clientPost := th.App.PreparePostForClient(post, false, false)
|
||||
|
||||
if shouldProxy {
|
||||
assert.Equal(t, fmt.Sprintf(postTemplate, imageURL), post.Message, "should not have mutated original post")
|
||||
@@ -482,7 +482,7 @@ func testProxyOpenGraphImage(t *testing.T, th *TestHelper, shouldProxy bool) {
|
||||
}, th.BasicChannel, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
embeds := th.App.PreparePostForClient(post, false).Metadata.Embeds
|
||||
embeds := th.App.PreparePostForClient(post, false, false).Metadata.Embeds
|
||||
require.Len(t, embeds, 1, "should have one embed")
|
||||
|
||||
embed := embeds[0]
|
||||
|
||||
Ссылка в новой задаче
Block a user