From 0d0aeffef1c59ca03993ad3f8d924aa2d970360e Mon Sep 17 00:00:00 2001 From: Teajey <21069848+Teajey@users.noreply.github.com> Date: Tue, 9 Dec 2025 00:20:54 +0900 Subject: [PATCH] UserList and GroupList for XML --- http/routing/groups.go | 8 +++++++- http/routing/users.go | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/http/routing/groups.go b/http/routing/groups.go index 9ceaa2b..8870be5 100644 --- a/http/routing/groups.go +++ b/http/routing/groups.go @@ -1,6 +1,7 @@ package routing import ( + "encoding/xml" "log" "net/http" "slices" @@ -143,6 +144,11 @@ func GroupPost(app *lishwist.Session, session *response.Session, h http.Header, return response.Data("", group) } +type GroupList struct { + XMLName xml.Name `xml:"Groups" json:"-"` + Groups []lishwist.Group `xml:"Group"` +} + func Groups(app *lishwist.Session, session *response.Session, h http.Header, r *http.Request) rsvp.Response { admin := app.Admin() if admin == nil { @@ -154,5 +160,5 @@ func Groups(app *lishwist.Session, session *response.Session, h http.Header, r * return response.Error(http.StatusInternalServerError, "Failed to get groups: %s", err) } - return response.Data("", groups) + return response.Data("", GroupList{Groups: groups}) } diff --git a/http/routing/users.go b/http/routing/users.go index d1f6a75..30f3c29 100644 --- a/http/routing/users.go +++ b/http/routing/users.go @@ -1,6 +1,7 @@ package routing import ( + "encoding/xml" lishwist "lishwist/core" "lishwist/http/response" "net/http" @@ -8,6 +9,11 @@ import ( "github.com/Teajey/rsvp" ) +type UserList struct { + XMLName xml.Name `xml:"Users" json:"-"` + Users []lishwist.User `xml:"User"` +} + func Users(app *lishwist.Session, session *response.Session, h http.Header, r *http.Request) rsvp.Response { admin := app.Admin() if admin == nil { @@ -19,7 +25,7 @@ func Users(app *lishwist.Session, session *response.Session, h http.Header, r *h return response.Error(http.StatusInternalServerError, "Failed to get users: %s", err) } - return response.Data("", users) + return response.Data("", UserList{Users: users}) } func User(app *lishwist.Session, session *response.Session, h http.Header, r *http.Request) rsvp.Response { -- 2.40.1