11460 user.get all profiles in channel (#11515)

Этот коммит содержится в:
Rodrigo Villablanca Vásquez
2019-07-05 10:18:45 -04:00
коммит произвёл Hanzei
родитель 8dfd3bab20
Коммит 11f1accac6
7 изменённых файлов: 137 добавлений и 118 удалений

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

@@ -1893,9 +1893,9 @@ func (a *App) ViewChannel(view *model.ChannelView, userId string, currentSession
}
func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
channelUsers := <-a.Srv.Store.User().GetAllProfilesInChannel(channel.Id, false)
if channelUsers.Err != nil {
return channelUsers.Err
profiles, err := a.Srv.Store.User().GetAllProfilesInChannel(channel.Id, false)
if err != nil {
return err
}
if err := a.Srv.Store.Post().PermanentDeleteByChannel(channel.Id); err != nil {
@@ -1920,7 +1920,7 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
if a.IsESIndexingEnabled() {
a.Srv.Go(func() {
for _, user := range channelUsers.Data.(map[string]*model.User) {
for _, user := range profiles {
if err := a.indexUser(user); err != nil {
mlog.Error("Encountered error indexing user", mlog.String("user_id", user.Id), mlog.Err(err))
}

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

@@ -28,7 +28,12 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
return []string{}, nil
}
pchan := a.Srv.Store.User().GetAllProfilesInChannel(channel.Id, true)
pchan := make(chan store.StoreResult, 1)
go func() {
props, err := a.Srv.Store.User().GetAllProfilesInChannel(channel.Id, true)
pchan <- store.StoreResult{Data: props, Err: err}
close(pchan)
}()
cmnchan := make(chan store.StoreResult, 1)
go func() {

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

@@ -550,11 +550,7 @@ func (a *App) GetUsersInChannelPageByStatus(channelId string, page int, perPage
}
func (a *App) GetUsersNotInChannel(teamId string, channelId string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) {
result := <-a.Srv.Store.User().GetProfilesNotInChannel(teamId, channelId, groupConstrained, offset, limit, viewRestrictions)
if result.Err != nil {
return nil, result.Err
}
return result.Data.([]*model.User), nil
return a.Srv.Store.User().GetProfilesNotInChannel(teamId, channelId, groupConstrained, offset, limit, viewRestrictions)
}
func (a *App) GetUsersNotInChannelMap(teamId string, channelId string, groupConstrained bool, offset int, limit int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) (map[string]*model.User, *model.AppError) {