PLT-6960 Only update post.EditAt when the message changes (#6840)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
1858fba7d4
Коммит
4bd7b68b24
@@ -266,9 +266,11 @@ func UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model.AppError
|
|||||||
newPost := &model.Post{}
|
newPost := &model.Post{}
|
||||||
*newPost = *oldPost
|
*newPost = *oldPost
|
||||||
|
|
||||||
|
if newPost.Message != post.Message {
|
||||||
newPost.Message = post.Message
|
newPost.Message = post.Message
|
||||||
newPost.EditAt = model.GetMillis()
|
newPost.EditAt = model.GetMillis()
|
||||||
newPost.Hashtags, _ = model.ParseHashtags(post.Message)
|
newPost.Hashtags, _ = model.ParseHashtags(post.Message)
|
||||||
|
}
|
||||||
|
|
||||||
if !safeUpdate {
|
if !safeUpdate {
|
||||||
newPost.IsPinned = post.IsPinned
|
newPost.IsPinned = post.IsPinned
|
||||||
|
|||||||
@@ -5,11 +5,37 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/mattermost/platform/model"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/mattermost/platform/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestUpdatePostEditAt(t *testing.T) {
|
||||||
|
th := Setup().InitBasic()
|
||||||
|
|
||||||
|
post := &model.Post{}
|
||||||
|
*post = *th.BasicPost
|
||||||
|
|
||||||
|
post.IsPinned = true
|
||||||
|
if saved, err := UpdatePost(post, true); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if saved.EditAt != post.EditAt {
|
||||||
|
t.Fatal("shouldn't have updated post.EditAt when pinning post")
|
||||||
|
|
||||||
|
*post = *saved
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(time.Millisecond * 100)
|
||||||
|
|
||||||
|
post.Message = model.NewId()
|
||||||
|
if saved, err := UpdatePost(post, true); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if saved.EditAt == post.EditAt {
|
||||||
|
t.Fatal("should have updated post.EditAt when updating post message")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
|
func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
|
||||||
// This test ensures that when replying to a root post made by a user who has since left the channel, the reply
|
// This test ensures that when replying to a root post made by a user who has since left the channel, the reply
|
||||||
// post completes successfully. This is a regression test for PLT-6523.
|
// post completes successfully. This is a regression test for PLT-6523.
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user