groupware: actually add total and limit to the email summary endpoint

This commit is contained in:
Pascal Bleser
2025-10-23 15:48:33 +02:00
parent 10b8142175
commit d4646eaf72
2 changed files with 29 additions and 1 deletions

View File

@@ -2070,6 +2070,10 @@ type Email struct {
// Note that this is not part of the JMAP specification, and is only calculated when requested.
ThreadSize int `json:"threadSize,omitzero"`
// The account ID this email belongs to.
// Note that this is not part of the JMAP specification, and is only contained in all-account operations.
AccountId string `json:"accountId,omitempty"`
// The set of Mailbox ids this Email belongs to.
//
// An Email in the mail store MUST belong to one or more Mailboxes at all times (until it is destroyed).

View File

@@ -1696,6 +1696,14 @@ type SwaggerGetLatestEmailsSummaryForAllAccountsParams struct {
Undesirable bool `json:"undesirable"`
}
type EmailSummaries struct {
Emails []EmailSummary `json:"emails,omitempty"`
Total uint `json:"total,omitzero"`
Limit uint `json:"limit,omitzero"`
Offset uint `json:"offset,omitzero"`
State jmap.State `json:"state,omitempty"`
}
// swagger:route GET /groupware/accounts/all/emails/latest/summary email get_latest_emails_summary_for_all_accounts
// Get a summary of the latest emails across all the mailboxes, across all of a user's accounts.
//
@@ -1725,6 +1733,17 @@ func (g *Groupware) GetLatestEmailsSummaryForAllAccounts(w http.ResponseWriter,
l = l.Uint(QueryParamLimit, limit)
}
offset, ok, err := req.parseUIntParam(QueryParamOffset, 0)
if err != nil {
return errorResponse(err)
}
if offset > 0 {
return notImplementesResponse()
}
if ok {
l = l.Uint(QueryParamOffset, limit)
}
seen, ok, err := req.parseBoolParam(QueryParamSeen, false)
if err != nil {
return errorResponse(err)
@@ -1784,7 +1803,12 @@ func (g *Groupware) GetLatestEmailsSummaryForAllAccounts(w http.ResponseWriter,
summaries[i] = summarizeEmail(all[i].accountId, all[i].email)
}
return response(summaries, sessionState, lang)
return response(EmailSummaries{
Emails: summaries,
Total: total,
Limit: limit,
Offset: offset,
}, sessionState, lang)
})
}