mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-23 13:30:14 -05:00
groupware: add /quota for all accounts
This commit is contained in:
@@ -4,20 +4,32 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/opencloud-eu/opencloud/pkg/log"
|
||||
"github.com/opencloud-eu/opencloud/pkg/structs"
|
||||
)
|
||||
|
||||
func (j *Client) GetQuotas(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (QuotaGetResponse, SessionState, Language, Error) {
|
||||
func (j *Client) GetQuotas(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string]QuotaGetResponse, SessionState, Language, Error) {
|
||||
logger = j.logger("GetQuotas", session, logger)
|
||||
cmd, err := j.request(session, logger, invocation(CommandQuotaGet, QuotaGetCommand{AccountId: accountId}, "0"))
|
||||
if err != nil {
|
||||
return QuotaGetResponse{}, "", "", err
|
||||
|
||||
uniqueAccountIds := structs.Uniq(accountIds)
|
||||
|
||||
invocations := make([]Invocation, len(uniqueAccountIds))
|
||||
for i, accountId := range uniqueAccountIds {
|
||||
invocations[i] = invocation(CommandQuotaGet, MailboxQueryCommand{AccountId: accountId}, mcid(accountId, "0"))
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (QuotaGetResponse, Error) {
|
||||
var response QuotaGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandQuotaGet, "0", &response)
|
||||
if err != nil {
|
||||
return QuotaGetResponse{}, err
|
||||
cmd, err := j.request(session, logger, invocations...)
|
||||
if err != nil {
|
||||
return nil, "", "", err
|
||||
}
|
||||
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]QuotaGetResponse, Error) {
|
||||
result := map[string]QuotaGetResponse{}
|
||||
for _, accountId := range uniqueAccountIds {
|
||||
var response QuotaGetResponse
|
||||
err = retrieveResponseMatchParameters(logger, body, CommandQuotaGet, mcid(accountId, "0"), &response)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result[accountId] = response
|
||||
}
|
||||
return response, nil
|
||||
return result, nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user