Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion synapseadmin/userapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -72,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"`
Expand All @@ -82,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.
Expand Down Expand Up @@ -128,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"`
}
Expand Down