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>
Этот коммит содержится в:
Agniva De Sarker
2024-02-14 20:59:46 +05:30
коммит произвёл GitHub
родитель 62f616dfbf
Коммит 28cb8d0441
9 изменённых файлов: 44 добавлений и 43 удалений

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

@@ -2686,7 +2686,7 @@ func (s *SqlPostStore) GetRepliesForExport(rootId string) ([]*model.ReplyForExpo
return posts, nil
}
func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string) ([]*model.DirectPostForExport, error) {
func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId string, includeArchivedChannels bool) ([]*model.DirectPostForExport, error) {
query := s.getQueryBuilder().
Select("p.*", "Users.Username as User").
From("Posts p").
@@ -2696,13 +2696,17 @@ func (s *SqlPostStore) GetDirectPostParentsForExportAfter(limit int, afterId str
sq.Gt{"p.Id": afterId},
sq.Eq{"p.RootId": ""},
sq.Eq{"p.DeleteAt": 0},
sq.Eq{"Channels.DeleteAt": 0},
sq.Eq{"Users.DeleteAt": 0},
sq.Eq{"Channels.Type": []model.ChannelType{model.ChannelTypeDirect, model.ChannelTypeGroup}},
}).
OrderBy("p.Id").
Limit(uint64(limit))
if !includeArchivedChannels {
query = query.Where(
sq.Eq{"Channels.DeleteAt": 0},
)
}
queryString, args, err := query.ToSql()
if err != nil {
return nil, errors.Wrap(err, "post_tosql")