Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,15 @@ func (cli *Client) ReportRoom(ctx context.Context, roomID id.RoomID, reason stri
return err
}

// AdminWhoIs fetches session information belonging to a specific user. Typically requires being a server admin.
//
// https://spec.matrix.org/v1.15/client-server-api/#get_matrixclientv3adminwhoisuserid
func (cli *Client) AdminWhoIs(ctx context.Context, userID id.UserID) (resp RespWhoIs, err error) {
urlPath := cli.BuildClientURL("v3", "admin", "whois", userID)
_, err = cli.MakeRequest(ctx, http.MethodGet, urlPath, nil, &resp)
return
}

// UnstableGetSuspendedStatus uses MSC4323 to check if a user is suspended.
func (cli *Client) UnstableGetSuspendedStatus(ctx context.Context, userID id.UserID) (res *RespSuspended, err error) {
urlPath := cli.BuildClientURL("unstable", "uk.timedout.msc4323", "admin", "suspend", userID)
Expand Down
20 changes: 20 additions & 0 deletions responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,3 +715,23 @@ type RespSuspended struct {
type RespLocked struct {
Locked bool `json:"locked"`
}

type ConnectionInfo struct {
IP string `json:"ip,omitempty"`
LastSeen jsontime.UnixMilli `json:"last_seen,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
}

type SessionInfo struct {
Connections []ConnectionInfo `json:"connections,omitempty"`
}

type DeviceInfo struct {
Sessions []SessionInfo `json:"sessions,omitempty"`
}

// RespWhoIs is the response body for https://spec.matrix.org/v1.15/client-server-api/#get_matrixclientv3adminwhoisuserid
type RespWhoIs struct {
UserID id.UserID `json:"user_id,omitempty"`
Devices map[id.Device]DeviceInfo `json:"devices,omitempty"`
}