MM-30865 Invalid Participants handling on post delete in thread (#16353)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
64499ca767
Коммит
1bd7dc41bd
@@ -1937,7 +1937,6 @@ func (s *SqlPostStore) cleanupThreads(postId, rootId, userId string, permanent b
|
||||
}
|
||||
if thread != nil {
|
||||
thread.ReplyCount -= 1
|
||||
thread.Participants = thread.Participants.Remove(userId)
|
||||
if _, err = s.Thread().Update(thread); err != nil {
|
||||
return errors.Wrap(err, "failed to update thread")
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
package storetest
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestThreadStore(t *testing.T, ss store.Store, s SqlSupplier) {
|
||||
@@ -120,7 +121,7 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
require.Nil(t, err, "couldn't get thread")
|
||||
require.NotNil(t, thread)
|
||||
require.Equal(t, int64(1), thread.ReplyCount)
|
||||
require.ElementsMatch(t, model.StringArray{newPosts[0].UserId}, thread.Participants)
|
||||
require.ElementsMatch(t, model.StringArray{newPosts[0].UserId, newPosts[1].UserId}, thread.Participants)
|
||||
})
|
||||
|
||||
t.Run("Update reply should update the UpdateAt of the thread", func(t *testing.T) {
|
||||
@@ -197,7 +198,7 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
thread2, err := ss.Thread().Get(rootPost.RootId)
|
||||
require.Nil(t, err)
|
||||
require.EqualValues(t, thread2.ReplyCount, 1)
|
||||
require.Len(t, thread2.Participants, 1)
|
||||
require.Len(t, thread2.Participants, 2)
|
||||
})
|
||||
|
||||
t.Run("Deleting root post should delete the thread", func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user