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>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f7446d7443
Коммит
8364e30a2a
@@ -4192,19 +4192,24 @@ func (s SqlChannelStore) GetChannelMembersForExport(userId string, teamId string
|
||||
return members, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string) ([]*model.DirectChannelForExport, error) {
|
||||
func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId string, includeArchivedChannels bool) ([]*model.DirectChannelForExport, error) {
|
||||
directChannelsForExport := []*model.DirectChannelForExport{}
|
||||
query := s.getQueryBuilder().
|
||||
Select("Channels.*").
|
||||
From("Channels").
|
||||
Where(sq.And{
|
||||
sq.Gt{"Channels.Id": afterId},
|
||||
sq.Eq{"Channels.DeleteAt": int(0)},
|
||||
sq.Eq{"Channels.Type": []model.ChannelType{model.ChannelTypeDirect, model.ChannelTypeGroup}},
|
||||
}).
|
||||
OrderBy("Channels.Id").
|
||||
Limit(uint64(limit))
|
||||
|
||||
if !includeArchivedChannels {
|
||||
query = query.Where(
|
||||
sq.Eq{"Channels.DeleteAt": int(0)},
|
||||
)
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "channel_tosql")
|
||||
@@ -4222,10 +4227,7 @@ func (s SqlChannelStore) GetAllDirectChannelsForExportAfter(limit int, afterId s
|
||||
Select("u.Username as Username, ChannelId, UserId, cm.Roles as Roles, LastViewedAt, MsgCount, MentionCount, MentionCountRoot, COALESCE(UrgentMentionCount, 0) UrgentMentionCount, cm.NotifyProps as NotifyProps, LastUpdateAt, SchemeUser, SchemeAdmin, (SchemeGuest IS NOT NULL AND SchemeGuest) as SchemeGuest").
|
||||
From("ChannelMembers cm").
|
||||
Join("Users u ON ( u.Id = cm.UserId )").
|
||||
Where(sq.And{
|
||||
sq.Eq{"cm.ChannelId": channelIds},
|
||||
sq.Eq{"u.DeleteAt": int(0)},
|
||||
})
|
||||
Where(sq.Eq{"cm.ChannelId": channelIds})
|
||||
|
||||
queryString, args, err = query.ToSql()
|
||||
if err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user