synapseadmin

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MPL-2.0 Imports: 12 Imported by: 1

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) BlockRoom added in v0.18.0

func (cli *Client) BlockRoom(ctx context.Context, roomID id.RoomID, req ReqBlockRoom) error

BlockRoom blocks or unblocks a room.

https://matrix-org.github.io/synapse/latest/admin_api/rooms.html#block-room-api

func (*Client) BuildAdminURL

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

func (*Client) CreateOrModifyAccount added in v0.18.0

func (cli *Client) CreateOrModifyAccount(ctx context.Context, userID id.UserID, req ReqCreateOrModifyAccount) error

CreateOrModifyAccount creates or modifies an account on the server.

https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#create-or-modify-account

func (*Client) DeactivateAccount added in v0.18.0

func (cli *Client) DeactivateAccount(ctx context.Context, userID id.UserID, req ReqDeleteUser) error

DeactivateAccount deactivates a specific local user account.

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

func (*Client) DeleteRoom added in v0.18.0

func (cli *Client) DeleteRoom(ctx context.Context, roomID id.RoomID, req ReqDeleteRoom) (RespDeleteRoom, error)

DeleteRoom deletes a room from the server, optionally blocking it and/or purging all data from the database.

This calls the async version of the endpoint, which will return immediately and delete the room in the background.

https://matrix-org.github.io/synapse/latest/admin_api/rooms.html#version-2-new-version

func (*Client) DeleteUserRatelimit added in v0.18.0

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

DeleteUserRatelimit deletes the ratelimit override for the given user, returning them to the default ratelimits.

https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#delete-ratelimit

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) GetRoomBlockStatus added in v0.18.0

func (cli *Client) GetRoomBlockStatus(ctx context.Context, roomID id.RoomID) (RoomsBlockResponse, error)

GetRoomBlockStatus gets whether a room is currently blocked.

https://matrix-org.github.io/synapse/latest/admin_api/rooms.html#get-block-status

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) GetUserRatelimit added in v0.18.0

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

GetUserRatelimit gets the ratelimit override for the given user.

https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#get-status-of-ratelimit

func (*Client) JoinUserToRoom added in v0.18.0

func (cli *Client) JoinUserToRoom(ctx context.Context, roomID id.RoomID, req ReqJoinUserToRoom) error

JoinUserToRoom makes a local user join the given room.

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

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) ListRooms added in v0.18.0

func (cli *Client) ListRooms(ctx context.Context, req ReqListRoom) (RespListRooms, error)

ListRooms returns a list of rooms on the server.

https://matrix-org.github.io/synapse/latest/admin_api/rooms.html#list-room-api

func (*Client) MakeRoomAdmin added in v0.18.0

func (cli *Client) MakeRoomAdmin(ctx context.Context, roomIDOrAlias string, req ReqMakeRoomAdmin) error

MakeRoomAdmin promotes a user to admin in a room. This requires that a local user has permission to promote users in the room.

https://matrix-org.github.io/synapse/latest/admin_api/rooms.html#make-room-admin-api

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) RoomMembers added in v0.18.0

func (cli *Client) RoomMembers(ctx context.Context, roomID id.RoomID) (RespRoomsMembers, error)

RoomMembers gets the full list of members in a room.

https://matrix-org.github.io/synapse/latest/admin_api/rooms.html#room-members-api

func (*Client) RoomMessages added in v0.18.0

func (cli *Client) RoomMessages(ctx context.Context, roomID id.RoomID, from, to string, dir mautrix.Direction, filter *mautrix.FilterPart, limit int) (resp *RespRoomMessages, err error)

RoomMessages returns a list of messages in a room.

https://matrix-org.github.io/synapse/latest/admin_api/rooms.html#room-messages-api

func (*Client) SetUserRatelimit added in v0.18.0

func (cli *Client) SetUserRatelimit(ctx context.Context, userID id.UserID, req ReqSetRatelimit) error

SetUserRatelimit overrides the message sending ratelimit for a specific user.

https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#set-ratelimit

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 RatelimitOverride added in v0.18.0

type RatelimitOverride struct {
	MessagesPerSecond int `json:"messages_per_second"`
	BurstCount        int `json:"burst_count"`
}

type ReqBlockRoom added in v0.18.0

type ReqBlockRoom struct {
	Block bool `json:"block"`
}

type ReqCreateOrModifyAccount added in v0.18.0

type ReqCreateOrModifyAccount struct {
	Password      string `json:"password,omitempty"`
	LogoutDevices *bool  `json:"logout_devices,omitempty"`

	Deactivated *bool `json:"deactivated,omitempty"`
	Admin       *bool `json:"admin,omitempty"`
	Locked      *bool `json:"locked,omitempty"`

	Displayname string              `json:"displayname,omitempty"`
	AvatarURL   id.ContentURIString `json:"avatar_url,omitempty"`
	UserType    string              `json:"user_type,omitempty"`
}

type ReqDeleteRoom added in v0.18.0

type ReqDeleteRoom struct {
	Purge         bool      `json:"purge,omitempty"`
	Block         bool      `json:"block,omitempty"`
	Message       string    `json:"message,omitempty"`
	RoomName      string    `json:"room_name,omitempty"`
	NewRoomUserID id.UserID `json:"new_room_user_id,omitempty"`
}

type ReqDeleteUser added in v0.18.0

type ReqDeleteUser struct {
	Erase bool `json:"erase"`
}

type ReqJoinUserToRoom added in v0.18.0

type ReqJoinUserToRoom struct {
	UserID id.UserID `json:"user_id"`
}

type ReqListRoom added in v0.18.0

type ReqListRoom struct {
	SearchTerm string
	OrderBy    string
	Direction  mautrix.Direction
	From       int
	Limit      int
}

func (*ReqListRoom) BuildQuery added in v0.18.0

func (req *ReqListRoom) BuildQuery() map[string]string

type ReqMakeRoomAdmin added in v0.18.0

type ReqMakeRoomAdmin struct {
	UserID id.UserID `json:"user_id"`
}

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 ReqSetRatelimit added in v0.18.0

type ReqSetRatelimit = RatelimitOverride

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 RespDeleteRoom added in v0.18.0

type RespDeleteRoom struct {
	DeleteID string `json:"delete_id"`
}

type RespListDevices

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

type RespListRooms added in v0.18.0

type RespListRooms struct {
	Rooms      []RoomInfo `json:"rooms"`
	Offset     int        `json:"offset"`
	TotalRooms int        `json:"total_rooms"`
	NextBatch  int        `json:"next_batch"`
	PrevBatch  int        `json:"prev_batch"`
}

type RespRoomMessages added in v0.18.0

type RespRoomMessages = mautrix.RespMessages

type RespRoomsMembers added in v0.18.0

type RespRoomsMembers struct {
	Members []id.UserID `json:"members"`
	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        bool                `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"`
}

type RespUserRatelimit added in v0.18.0

type RespUserRatelimit = RatelimitOverride

type RoomInfo added in v0.18.0

type RoomInfo struct {
	RoomID             id.RoomID               `json:"room_id"`
	Name               string                  `json:"name"`
	CanonicalAlias     id.RoomAlias            `json:"canonical_alias"`
	JoinedMembers      int                     `json:"joined_members"`
	JoinedLocalMembers int                     `json:"joined_local_members"`
	Version            string                  `json:"version"`
	Creator            id.UserID               `json:"creator"`
	Encryption         id.Algorithm            `json:"encryption"`
	Federatable        bool                    `json:"federatable"`
	Public             bool                    `json:"public"`
	JoinRules          event.JoinRule          `json:"join_rules"`
	GuestAccess        event.GuestAccess       `json:"guest_access"`
	HistoryVisibility  event.HistoryVisibility `json:"history_visibility"`
	StateEvents        int                     `json:"state_events"`
	RoomType           event.RoomType          `json:"room_type"`
}

type RoomsBlockResponse added in v0.18.0

type RoomsBlockResponse struct {
	Block  bool      `json:"block"`
	UserID id.UserID `json:"user_id"`
}

RoomsBlockResponse represents the response containing wether a room is blocked or not

Jump to

Keyboard shortcuts

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