MM-55524: Include deactivated users in DM export (#25695)

We were incorrectly excluding deactivated users
while getting channel members for a DM channel, whereas
we were actually exporting all users in the users array.

We fix this and also correctly honor the includeArchivedChannels
flag as well.

https://mattermost.atlassian.net/browse/MM-55524

```release-note
Include deactivated members in a favorited DM channel export.
```


---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Agniva De Sarker
2024-01-20 08:47:47 +05:30
коммит произвёл GitHub
родитель f7446d7443
Коммит 8364e30a2a
9 изменённых файлов: 49 добавлений и 42 удалений

Просмотреть файл

@@ -120,7 +120,7 @@ func (a *App) BulkExport(ctx request.CTX, writer io.Writer, outPath string, job
}
ctx.Logger().Info("Bulk export: exporting direct channels")
if err = a.exportAllDirectChannels(ctx, job, writer); err != nil {
if err = a.exportAllDirectChannels(ctx, job, writer, opts.IncludeArchivedChannels); err != nil {
return err
}
@@ -663,11 +663,11 @@ func (a *App) copyEmojiImages(emojiId string, emojiImagePath string, pathToDir s
return nil
}
func (a *App) exportAllDirectChannels(ctx request.CTX, job *model.Job, writer io.Writer) *model.AppError {
func (a *App) exportAllDirectChannels(ctx request.CTX, job *model.Job, writer io.Writer, includeArchivedChannels bool) *model.AppError {
afterId := strings.Repeat("0", 26)
cnt := 0
for {
channels, err := a.Srv().Store().Channel().GetAllDirectChannelsForExportAfter(1000, afterId)
channels, err := a.Srv().Store().Channel().GetAllDirectChannelsForExportAfter(1000, afterId, includeArchivedChannels)
if err != nil {
return model.NewAppError("exportAllDirectChannels", "app.channel.get_all_direct.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
}