From 035f60e84ceb9167104848134b9b3bda90931152 Mon Sep 17 00:00:00 2001 From: eiabea Date: Wed, 10 Jun 2026 09:52:13 +0200 Subject: [PATCH 1/2] feat: add ListAccounts function --- synapseadmin/userapi.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/synapseadmin/userapi.go b/synapseadmin/userapi.go index 8c5252391..57d1f48e6 100644 --- a/synapseadmin/userapi.go +++ b/synapseadmin/userapi.go @@ -61,6 +61,33 @@ type RespListDevices struct { Total int `json:"total"` } +type AccountInfo struct { + UserID id.UserID `json:"name"` + DisplayName string `json:"displayname"` + AvatarURL id.ContentURIString `json:"avatar_url"` + Guest bool `json:"is_guest"` + Admin bool `json:"admin"` + UserType string `json:"user_type"` + Deactivated bool `json:"deactivated"` + ShadowBanned bool `json:"shadow_banned"` + CreationTS jsontime.Unix `json:"creation_ts"` +} + +type RespListAccounts struct { + Users []AccountInfo `json:"users"` + NextToken string `json:"next_token"` + Total int `json:"total"` +} + +// ListAccounts returns a list of local user accounts on the server. +// +// https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#list-accounts +func (cli *Client) ListAccounts(ctx context.Context) (resp RespListAccounts, err error) { + // TODO add query parameters described in the documentation + _, err = cli.Client.MakeRequest(ctx, http.MethodGet, cli.BuildAdminURL("v2", "users"), nil, &resp) + return resp, err +} + // ListDevices gets information about all the devices of a specific user. // // https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#list-all-devices From 1755ad29ebf2f60e44da910328c0e780d1da728c Mon Sep 17 00:00:00 2001 From: eiabea Date: Wed, 10 Jun 2026 09:53:05 +0200 Subject: [PATCH 2/2] feat: add threepid to CreateOrModifyAccount and RespUserInfo --- synapseadmin/userapi.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/synapseadmin/userapi.go b/synapseadmin/userapi.go index 57d1f48e6..d9474b6ef 100644 --- a/synapseadmin/userapi.go +++ b/synapseadmin/userapi.go @@ -99,6 +99,7 @@ func (cli *Client) ListDevices(ctx context.Context, userID id.UserID) (resp *Res type RespUserInfo struct { UserID id.UserID `json:"name"` DisplayName string `json:"displayname"` + Threepids []ThreePID `json:"threepids"` AvatarURL id.ContentURIString `json:"avatar_url"` Guest bool `json:"is_guest"` Admin bool `json:"admin"` @@ -109,7 +110,14 @@ type RespUserInfo struct { AppserviceID string `json:"appservice_id"` UserType string `json:"user_type"` - // TODO: consent fields, threepids, external IDs + // TODO: consent fields, external IDs +} + +type ThreePID struct { + Medium string `json:"medium"` + Address string `json:"address"` + AddedAt jsontime.Unix `json:"added_at"` + ValidatedAt jsontime.Unix `json:"validated_at"` } // GetUserInfo gets information about a specific user account. @@ -155,6 +163,7 @@ type ReqCreateOrModifyAccount struct { Locked *bool `json:"locked,omitempty"` Displayname string `json:"displayname,omitempty"` + Threepids []ThreePID `json:"threepids,omitempty"` AvatarURL id.ContentURIString `json:"avatar_url,omitempty"` UserType string `json:"user_type,omitempty"` }