From b42c00a5013e99de8a9fdb6e3f82a24459467543 Mon Sep 17 00:00:00 2001 From: Pascal Bleser Date: Thu, 23 Oct 2025 15:48:33 +0200 Subject: [PATCH] groupware: actually add total and limit to the email summary endpoint --- pkg/jmap/jmap_model.go | 4 +++ .../pkg/groupware/groupware_api_emails.go | 26 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pkg/jmap/jmap_model.go b/pkg/jmap/jmap_model.go index 4f1122fa34..79bdce1cd7 100644 --- a/pkg/jmap/jmap_model.go +++ b/pkg/jmap/jmap_model.go @@ -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). diff --git a/services/groupware/pkg/groupware/groupware_api_emails.go b/services/groupware/pkg/groupware/groupware_api_emails.go index 872dd11ccd..1ffca3926f 100644 --- a/services/groupware/pkg/groupware/groupware_api_emails.go +++ b/services/groupware/pkg/groupware/groupware_api_emails.go @@ -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) }) }