synapseadmin

package
v0.16.2-mod-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*mautrix.Client
}

Client is a wrapper for the mautrix.Client struct that includes methods for accessing the Synapse admin API.

https://matrix-org.github.io/synapse/latest/usage/administration/admin_api/index.html

func (*Client) BuildAdminURL

func (cli *Client) BuildAdminURL(path ...any) string

func (*Client) GetRegisterNonce

func (cli *Client) GetRegisterNonce(ctx context.Context) (string, error)

GetRegisterNonce gets a nonce that can be used for SharedSecretRegister.

This does not need to be called manually as SharedSecretRegister will automatically call this if no nonce is provided.

func (*Client) GetUserInfo

func (cli *Client) GetUserInfo(ctx context.Context, userID id.UserID) (resp *RespUserInfo, err error)

GetUserInfo gets information about a specific user account.

https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#query-user-account

func (*Client) ListDevices

func (cli *Client) ListDevices(ctx context.Context, userID id.UserID) (resp *RespListDevices, err error)

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

func (*Client) ResetPassword

func (cli *Client) ResetPassword(ctx context.Context, req ReqResetPassword) error

ResetPassword changes the password of another user using

https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#reset-password

func (*Client) SharedSecretRegister

func (cli *Client) SharedSecretRegister(ctx context.Context, sharedSecret string, req ReqSharedSecretRegister) (*mautrix.RespRegister, error)

SharedSecretRegister creates a new account using a shared secret.

https://matrix-org.github.io/synapse/latest/admin_api/register_api.html

func (*Client) UsernameAvailable

func (cli *Client) UsernameAvailable(ctx context.Context, username string) (resp *mautrix.RespRegisterAvailable, err error)

UsernameAvailable checks if a username is valid and available for registration on the server using the admin API.

The response format is the same as mautrix.Client.RegisterAvailable, but it works even if registration is disabled on the server.

https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#check-username-availability

type DeviceInfo

type DeviceInfo struct {
	mautrix.RespDeviceInfo
	LastSeenUserAgent string `json:"last_seen_user_agent"`
}

type ReqResetPassword

type ReqResetPassword struct {
	// The user whose password to reset.
	UserID id.UserID `json:"-"`

	// The new password for the user. Required.
	NewPassword string `json:"new_password"`
	// Whether all the user's existing devices should be logged out after the password change.
	LogoutDevices bool `json:"logout_devices"`
}

ReqResetPassword is the request content for Client.ResetPassword.

type ReqSharedSecretRegister

type ReqSharedSecretRegister struct {
	// The username to register. Required.
	Username string `json:"username"`
	// The new password for the user. Required.
	Password string `json:"password"`

	// Initial displayname for the user. By default, the server will use the username as the displayname.
	Displayname string `json:"displayname,omitempty"`
	// The type of user to register. Defaults to empty (normal user).
	// Officially allowed values are "support" or "bot".
	//
	// Currently, the only effect is that synapse skips consent requirements for those two user types,
	// other than that the user type does absolutely nothing.
	UserType string `json:"user_type,omitempty"`
	// Whether the created user should be a server admin.
	Admin bool `json:"admin"`
	// Disable generating a new device along with the registration.
	// If true, the access_token and device_id fields in the response will be empty.
	InhibitLogin bool `json:"inhibit_login,omitempty"`

	// A single-use nonce from GetRegisterNonce. This is automatically filled by Client.SharedSecretRegister if left empty.
	Nonce string `json:"nonce"`
	// The checksum for the request. This is automatically generated by Client.SharedSecretRegister using Sign.
	SHA1Checksum string `json:"mac"`
}

ReqSharedSecretRegister is the request content for Client.SharedSecretRegister.

func (*ReqSharedSecretRegister) Sign

func (req *ReqSharedSecretRegister) Sign(secret string) string

type RespListDevices

type RespListDevices struct {
	Devices []DeviceInfo `json:"devices"`
	Total   int          `json:"total"`
}

type RespUserInfo

type RespUserInfo struct {
	UserID       id.UserID           `json:"name"`
	DisplayName  string              `json:"displayname"`
	AvatarURL    id.ContentURIString `json:"avatar_url"`
	Guest        int                 `json:"is_guest"`
	Admin        bool                `json:"admin"`
	Deactivated  bool                `json:"deactivated"`
	Erased       bool                `json:"erased"`
	ShadowBanned bool                `json:"shadow_banned"`
	CreationTS   jsontime.Unix       `json:"creation_ts"`
	AppserviceID string              `json:"appservice_id"`
	UserType     string              `json:"user_type"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL