mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 12:50:21 -06:00
Use LoadAccounts in accounts handler
This commit is contained in:
@@ -146,6 +146,26 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest
|
||||
return nil
|
||||
}
|
||||
|
||||
if in.Query == "" {
|
||||
err = s.repo.LoadAccounts(ctx, &out.Accounts)
|
||||
if err != nil {
|
||||
s.log.Err(err).Msg("failed to load all accounts from storage")
|
||||
return merrors.InternalServerError(s.id, "failed to load all accounts")
|
||||
}
|
||||
for i := range out.Accounts {
|
||||
a := out.Accounts[i]
|
||||
|
||||
// TODO add groups only if requested
|
||||
// if in.FieldMask ...
|
||||
s.expandMemberOf(a)
|
||||
|
||||
if a.PasswordProfile != nil {
|
||||
a.PasswordProfile.Password = ""
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
searchResults, err := s.findAccountsByQuery(ctx, in.Query)
|
||||
out.Accounts = make([]*proto.Account, 0, len(searchResults))
|
||||
|
||||
@@ -180,10 +200,6 @@ func (s Service) findAccountsByQuery(ctx context.Context, query string) ([]strin
|
||||
var searchResults []string
|
||||
var err error
|
||||
|
||||
if query == "" {
|
||||
return s.index.FindByPartial(&proto.Account{}, "Mail", "*")
|
||||
}
|
||||
|
||||
// TODO: more explicit queries have to be on top
|
||||
var onPremOrMailQuery = regexp.MustCompile(`^on_premises_sam_account_name eq '(.*)' or mail eq '(.*)'$`)
|
||||
match := onPremOrMailQuery.FindStringSubmatch(query)
|
||||
|
||||
@@ -2,6 +2,8 @@ Change: Rebuild index command for accounts
|
||||
|
||||
Tags: accounts
|
||||
|
||||
The index for the accounts service can now be rebuilt by running the cli command `./bin/ocis accounts rebuild`. It deletes all configured indices and rebuilds them from the documents found on storage.
|
||||
The index for the accounts service can now be rebuilt by running the cli command `./bin/ocis accounts rebuild`.
|
||||
It deletes all configured indices and rebuilds them from the documents found on storage. For this we also introduced
|
||||
a `LoadAccounts` and `LoadGroups` function on storage for loading all existing documents.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/748
|
||||
|
||||
Reference in New Issue
Block a user