diff --git a/pkg/jmap/jmap_api_email.go b/pkg/jmap/jmap_api_email.go index 208c785e1d..54d571072e 100644 --- a/pkg/jmap/jmap_api_email.go +++ b/pkg/jmap/jmap_api_email.go @@ -185,7 +185,6 @@ func (j *Client) GetAllEmailsInMailbox(accountId string, session *Session, ctx c Total: queryResponse.Total, Limit: queryResponse.Limit, Offset: queryResponse.Position, - State: getResponse.State, }, nil }) } @@ -930,6 +929,9 @@ func (j *Client) EmailsInThread(accountId string, threadId string, session *Sess type EmailsSummary struct { Emails []Email `json:"emails"` + Total int `json:"total"` + Limit int `json:"limit"` + Offset int `json:"offset"` State State `json:"state"` } @@ -993,16 +995,22 @@ func (j *Client) QueryEmailSummaries(accountIds []string, session *Session, ctx } cmd, err := j.request(session, logger, invocations...) if err != nil { - return map[string]EmailsSummary{}, "", "", err + return nil, "", "", err } return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]EmailsSummary, Error) { resp := map[string]EmailsSummary{} for _, accountId := range uniqueAccountIds { + var queryResponse EmailQueryResponse + err = retrieveResponseMatchParameters(logger, body, CommandEmailQuery, mcid(accountId, "0"), &queryResponse) + if err != nil { + return nil, err + } + var response EmailGetResponse err = retrieveResponseMatchParameters(logger, body, CommandEmailGet, mcid(accountId, "1"), &response) if err != nil { - return map[string]EmailsSummary{}, err + return nil, err } if len(response.NotFound) > 0 { // TODO what to do when there are not-found emails here? potentially nothing, they could have been deleted between query and get? @@ -1016,7 +1024,13 @@ func (j *Client) QueryEmailSummaries(accountIds []string, session *Session, ctx setThreadSize(&thread, response.List) } - resp[accountId] = EmailsSummary{Emails: response.List, State: response.State} + resp[accountId] = EmailsSummary{ + Emails: response.List, + Total: int(queryResponse.Total), + Limit: int(queryResponse.Limit), + Offset: int(queryResponse.Position), + State: response.State, + } } return resp, nil }) diff --git a/services/groupware/pkg/groupware/groupware_api_emails.go b/services/groupware/pkg/groupware/groupware_api_emails.go index a1c776be07..872dd11ccd 100644 --- a/services/groupware/pkg/groupware/groupware_api_emails.go +++ b/services/groupware/pkg/groupware/groupware_api_emails.go @@ -131,7 +131,6 @@ func (g *Groupware) GetAllEmailsInMailbox(w http.ResponseWriter, r *http.Request Total: emails.Total, Limit: emails.Limit, Offset: emails.Offset, - State: emails.State, } return etagResponse(safe, sessionState, emails.State, lang)