MM-56579: Include deactivated users from DM posts (#25985)
There were 2 separate bugs here: 1. We were not including deactivated users while fetching posts from DM channels. 2. We were not respecting the includeArchivedChannels flag while fetching DM channels. We fix both of these issues here. ```release-note Include posts from deactivated users in DM channel export. Also respect the --include-archived-channels flag for DM channels. ``` https://mattermost.atlassian.net/browse/MM-56579 Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
62f616dfbf
Коммит
28cb8d0441
@@ -125,7 +125,7 @@ func (a *App) BulkExport(ctx request.CTX, writer io.Writer, outPath string, job
|
||||
}
|
||||
|
||||
ctx.Logger().Info("Bulk export: exporting direct posts")
|
||||
directAttachments, err := a.exportAllDirectPosts(ctx, job, writer, opts.IncludeAttachments)
|
||||
directAttachments, err := a.exportAllDirectPosts(ctx, job, writer, opts.IncludeAttachments, opts.IncludeArchivedChannels)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -729,7 +729,7 @@ func (a *App) buildFavoritedByList(channelID string) ([]string, *model.AppError)
|
||||
return userIDs, nil
|
||||
}
|
||||
|
||||
func (a *App) exportAllDirectPosts(ctx request.CTX, job *model.Job, writer io.Writer, withAttachments bool) ([]imports.AttachmentImportData, *model.AppError) {
|
||||
func (a *App) exportAllDirectPosts(ctx request.CTX, job *model.Job, writer io.Writer, withAttachments, includeArchivedChannels bool) ([]imports.AttachmentImportData, *model.AppError) {
|
||||
var attachments []imports.AttachmentImportData
|
||||
afterId := strings.Repeat("0", 26)
|
||||
var postProcessCount uint64
|
||||
@@ -742,7 +742,7 @@ func (a *App) exportAllDirectPosts(ctx request.CTX, job *model.Job, writer io.Wr
|
||||
logCheckpoint = time.Now()
|
||||
}
|
||||
|
||||
posts, err := a.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, afterId)
|
||||
posts, err := a.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, afterId, includeArchivedChannels)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("exportAllDirectPosts", "app.post.get_direct_posts.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ func TestExportDMandGMPost(t *testing.T) {
|
||||
}
|
||||
th1.App.CreatePost(th1.Context, p4, gmChannel, false, true)
|
||||
|
||||
posts, err := th1.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts, err := th1.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 4, len(posts))
|
||||
|
||||
@@ -478,7 +478,7 @@ func TestExportDMandGMPost(t *testing.T) {
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
|
||||
posts, err = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts, err = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 0, len(posts))
|
||||
|
||||
@@ -487,7 +487,7 @@ func TestExportDMandGMPost(t *testing.T) {
|
||||
assert.Nil(t, appErr)
|
||||
assert.Equal(t, 0, i)
|
||||
|
||||
posts, err = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts, err = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Adding some determinism so its possible to assert on slice index
|
||||
@@ -538,7 +538,7 @@ func TestExportPostWithProps(t *testing.T) {
|
||||
}
|
||||
th1.App.CreatePost(th1.Context, p2, gmChannel, false, true)
|
||||
|
||||
posts, err := th1.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts, err := th1.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, posts, 2)
|
||||
require.NotEmpty(t, posts[0].Props)
|
||||
@@ -553,7 +553,7 @@ func TestExportPostWithProps(t *testing.T) {
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
|
||||
posts, err = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts, err = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, posts, 0)
|
||||
|
||||
@@ -562,7 +562,7 @@ func TestExportPostWithProps(t *testing.T) {
|
||||
assert.Nil(t, appErr)
|
||||
assert.Equal(t, 0, i)
|
||||
|
||||
posts, err = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts, err = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Adding some determinism so its possible to assert on slice index
|
||||
@@ -586,7 +586,7 @@ func TestExportDMPostWithSelf(t *testing.T) {
|
||||
err := th1.App.BulkExport(th1.Context, &b, "somePath", nil, model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
posts, nErr := th1.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts, nErr := th1.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
|
||||
require.NoError(t, nErr)
|
||||
assert.Equal(t, 1, len(posts))
|
||||
|
||||
@@ -595,7 +595,7 @@ func TestExportDMPostWithSelf(t *testing.T) {
|
||||
th2 := Setup(t)
|
||||
defer th2.TearDown()
|
||||
|
||||
posts, nErr = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts, nErr = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
|
||||
require.NoError(t, nErr)
|
||||
assert.Equal(t, 0, len(posts))
|
||||
|
||||
@@ -604,7 +604,7 @@ func TestExportDMPostWithSelf(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, i)
|
||||
|
||||
posts, nErr = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
posts, nErr = th2.App.Srv().Store().Post().GetDirectPostParentsForExportAfter(1000, "0000000", false)
|
||||
require.NoError(t, nErr)
|
||||
assert.Equal(t, 1, len(posts))
|
||||
assert.Equal(t, 1, len((*posts[0].ChannelMembers)))
|
||||
|
||||
Ссылка в новой задаче
Block a user