From 95ed9d68e5b943ecf5fd0d4ad061700fe3c96994 Mon Sep 17 00:00:00 2001
From: Pascal Bleser
Date: Fri, 24 Oct 2025 17:11:54 +0200
Subject: [PATCH] groupware: change /accounts endpoint to return an array with
the accountId instead of a map
---
.../pkg/groupware/groupware_api_account.go | 20 ++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/services/groupware/pkg/groupware/groupware_api_account.go b/services/groupware/pkg/groupware/groupware_api_account.go
index 1909f2fde2..0448e89cea 100644
--- a/services/groupware/pkg/groupware/groupware_api_account.go
+++ b/services/groupware/pkg/groupware/groupware_api_account.go
@@ -2,6 +2,8 @@ package groupware
import (
"net/http"
+ "slices"
+ "strings"
"github.com/opencloud-eu/opencloud/pkg/jmap"
)
@@ -52,10 +54,26 @@ type SwaggerGetAccountsResponse struct {
// 500: ErrorResponse500
func (g *Groupware) GetAccounts(w http.ResponseWriter, r *http.Request) {
g.respond(w, r, func(req Request) Response {
- return response(req.session.Accounts, req.session.State, "")
+ list := make([]AccountWithId, len(req.session.Accounts))
+ i := 0
+ for accountId, account := range req.session.Accounts {
+ list[i] = AccountWithId{
+ AccountId: accountId,
+ Account: account,
+ }
+ i++
+ }
+ // sort on accountId to have a stable order that remains the same with every query
+ slices.SortFunc(list, func(a, b AccountWithId) int { return strings.Compare(a.AccountId, b.AccountId) })
+ return response(list, req.session.State, "")
})
}
+type AccountWithId struct {
+ AccountId string `json:"accountId,omitempty"`
+ jmap.Account
+}
+
type AccountBootstrapResponse struct {
// The API version.
Version string `json:"version"`