[MM-44159] Add user sort by admin status in channels (#20562)
Этот коммит содержится в:
@@ -771,6 +771,37 @@ func (us SqlUserStore) GetProfilesInChannelByStatus(options *model.UserGetOption
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) GetProfilesInChannelByAdmin(options *model.UserGetOptions) ([]*model.User, error) {
|
||||
query := us.usersQuery.
|
||||
Join("ChannelMembers cm ON ( cm.UserId = u.Id )").
|
||||
Where("cm.ChannelId = ?", options.InChannelId).
|
||||
OrderBy(`cm.SchemeAdmin DESC`).
|
||||
OrderBy("u.Username ASC").
|
||||
Offset(uint64(options.Page * options.PerPage)).Limit(uint64(options.PerPage))
|
||||
|
||||
if options.Inactive && !options.Active {
|
||||
query = query.Where("u.DeleteAt != 0")
|
||||
} else if options.Active && !options.Inactive {
|
||||
query = query.Where("u.DeleteAt = 0")
|
||||
}
|
||||
|
||||
queryString, args, err := query.ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get_profiles_in_channel_by_admin_tosql")
|
||||
}
|
||||
|
||||
users := []*model.User{}
|
||||
if err := us.GetReplicaX().Select(&users, queryString, args...); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to find Users")
|
||||
}
|
||||
|
||||
for _, u := range users {
|
||||
u.Sanitize(map[string]bool{})
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func (us SqlUserStore) GetAllProfilesInChannel(ctx context.Context, channelID string, allowFromCache bool) (map[string]*model.User, error) {
|
||||
query := us.usersQuery.
|
||||
Join("ChannelMembers cm ON ( cm.UserId = u.Id )").
|
||||
|
||||
Ссылка в новой задаче
Block a user