package synapseadmin
import "maunium.net/go/mautrix/synapseadmin"
Index ¶
- type Client
- func (cli *Client) BlockRoom(ctx context.Context, roomID id.RoomID, req ReqBlockRoom) error
- func (cli *Client) BuildAdminURL(path ...any) string
- func (cli *Client) CreateOrModifyAccount(ctx context.Context, userID id.UserID, req ReqCreateOrModifyAccount) error
- func (cli *Client) DeactivateAccount(ctx context.Context, userID id.UserID, req ReqDeleteUser) error
- func (cli *Client) DeleteRoom(ctx context.Context, roomID id.RoomID, req ReqDeleteRoom) (RespDeleteRoom, error)
- func (cli *Client) DeleteRoomStatus(ctx context.Context, deleteID string) (resp RespDeleteRoomStatus, err error)
- func (cli *Client) DeleteRoomSync(ctx context.Context, roomID id.RoomID, req ReqDeleteRoom) (resp RespDeleteRoomResult, err error)
- func (cli *Client) DeleteUserRatelimit(ctx context.Context, userID id.UserID) (err error)
- func (cli *Client) GetRegisterNonce(ctx context.Context) (string, error)
- func (cli *Client) GetRoomBlockStatus(ctx context.Context, roomID id.RoomID) (RoomsBlockResponse, error)
- func (cli *Client) GetUserInfo(ctx context.Context, userID id.UserID) (resp *RespUserInfo, err error)
- func (cli *Client) GetUserRatelimit(ctx context.Context, userID id.UserID) (resp RespUserRatelimit, err error)
- func (cli *Client) JoinUserToRoom(ctx context.Context, roomID id.RoomID, req ReqJoinUserToRoom) error
- func (cli *Client) ListDevices(ctx context.Context, userID id.UserID) (resp *RespListDevices, err error)
- func (cli *Client) ListRooms(ctx context.Context, req ReqListRoom) (RespListRooms, error)
- func (cli *Client) MakeRoomAdmin(ctx context.Context, roomIDOrAlias string, req ReqMakeRoomAdmin) error
- func (cli *Client) ResetPassword(ctx context.Context, req ReqResetPassword) error
- func (cli *Client) RoomInfo(ctx context.Context, roomID id.RoomID) (resp *RoomInfo, err error)
- func (cli *Client) RoomMembers(ctx context.Context, roomID id.RoomID) (RespRoomsMembers, error)
- 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)
- func (cli *Client) SetUserRatelimit(ctx context.Context, userID id.UserID, req ReqSetRatelimit) error
- func (cli *Client) SharedSecretRegister(ctx context.Context, sharedSecret string, req ReqSharedSecretRegister) (*mautrix.RespRegister, error)
- func (cli *Client) SuspendAccount(ctx context.Context, userID id.UserID, req ReqSuspendUser) error
- func (cli *Client) UsernameAvailable(ctx context.Context, username string) (resp *mautrix.RespRegisterAvailable, err error)
- type DeviceInfo
- type RatelimitOverride
- type ReqBlockRoom
- type ReqCreateOrModifyAccount
- type ReqDeleteRoom
- type ReqDeleteUser
- type ReqJoinUserToRoom
- type ReqListRoom
- type ReqMakeRoomAdmin
- type ReqResetPassword
- type ReqSetRatelimit
- type ReqSharedSecretRegister
- type ReqSuspendUser
- type RespDeleteRoom
- type RespDeleteRoomResult
- type RespDeleteRoomStatus
- type RespListDevices
- type RespListRooms
- type RespRoomMessages
- type RespRoomsMembers
- type RespUserInfo
- type RespUserRatelimit
- type RoomInfo
- type RoomsBlockResponse
Types ¶
type 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 ¶
BlockRoom blocks or unblocks a room.
https://matrix-org.github.io/synapse/latest/admin_api/rooms.html#block-room-api
func (*Client) BuildAdminURL ¶
func (*Client) CreateOrModifyAccount ¶
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 ¶
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 ¶
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) DeleteRoomStatus ¶
func (cli *Client) DeleteRoomStatus(ctx context.Context, deleteID string) (resp RespDeleteRoomStatus, err error)
func (*Client) DeleteRoomSync ¶
func (cli *Client) DeleteRoomSync(ctx context.Context, roomID id.RoomID, req ReqDeleteRoom) (resp RespDeleteRoomResult, err error)
DeleteRoomSync deletes a room from the server, optionally blocking it and/or purging all data from the database.
This calls the synchronous version of the endpoint, which will block until the room is deleted.
https://element-hq.github.io/synapse/latest/admin_api/rooms.html#version-1-old-version
func (*Client) DeleteUserRatelimit ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) RoomInfo ¶
func (*Client) RoomMembers ¶
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 ¶
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 ¶
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) SuspendAccount ¶
SuspendAccount suspends or unsuspends a specific local user account.
https://element-hq.github.io/synapse/latest/admin_api/user_admin_api.html#suspendunsuspend-account
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.
type DeviceInfo ¶
type DeviceInfo struct { mautrix.RespDeviceInfo LastSeenUserAgent string `json:"last_seen_user_agent"` }
type RatelimitOverride ¶
type RatelimitOverride struct { MessagesPerSecond int `json:"messages_per_second"` BurstCount int `json:"burst_count"` }
type ReqBlockRoom ¶
type ReqBlockRoom struct { Block bool `json:"block"` }
type ReqCreateOrModifyAccount ¶
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 ¶
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 ¶
type ReqDeleteUser struct { Erase bool `json:"erase"` }
type ReqJoinUserToRoom ¶
type ReqListRoom ¶
type ReqListRoom struct { SearchTerm string OrderBy string Direction mautrix.Direction From int Limit int }
func (*ReqListRoom) BuildQuery ¶
func (req *ReqListRoom) BuildQuery() map[string]string
type ReqMakeRoomAdmin ¶
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 ¶
type ReqSetRatelimit = RatelimitOverride
type ReqSharedSecretRegister ¶
type ReqSharedSecretRegister struct { // The username to register. Required. string `json:"username"` // The new password for the user. Required. string `json:"password"` // Initial displayname for the user. By default, the server will use the username as the 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. string `json:"user_type,omitempty"` // Whether the created user should be a server 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. bool `json:"inhibit_login,omitempty"` // A single-use nonce from GetRegisterNonce. This is automatically filled by Client.SharedSecretRegister if left empty. string `json:"nonce"` // The checksum for the request. This is automatically generated by Client.SharedSecretRegister using Sign. string `json:"mac"` }
ReqSharedSecretRegister is the request content for Client.SharedSecretRegister.
func (*ReqSharedSecretRegister) Sign ¶
func (req *ReqSharedSecretRegister) Sign(secret string) string
type ReqSuspendUser ¶
type ReqSuspendUser struct { Suspend bool `json:"suspend"` }
type RespDeleteRoom ¶
type RespDeleteRoom struct { DeleteID string `json:"delete_id"` }
type RespDeleteRoomResult ¶
type RespDeleteRoomResult struct { KickedUsers []id.UserID `json:"kicked_users,omitempty"` FailedToKickUsers []id.UserID `json:"failed_to_kick_users,omitempty"` LocalAliases []id.RoomAlias `json:"local_aliases,omitempty"` NewRoomID id.RoomID `json:"new_room_id,omitempty"` }
type RespDeleteRoomStatus ¶
type RespDeleteRoomStatus struct { Status string `json:"status,omitempty"` Error string `json:"error,omitempty"` ShutdownRoom RespDeleteRoomResult `json:"shutdown_room,omitempty"` }
type RespListDevices ¶
type RespListDevices struct { Devices []DeviceInfo `json:"devices"` Total int `json:"total"` }
type RespListRooms ¶
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 ¶
type RespRoomMessages = mautrix.RespMessages
type RespRoomsMembers ¶
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 ¶
type RespUserRatelimit = RatelimitOverride
type RoomInfo ¶
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 ¶
RoomsBlockResponse represents the response containing wether a room is blocked or not
Source Files ¶
client.go register.go roomapi.go userapi.go
- Version
- v0.24.1 (latest)
- Published
- Jun 16, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 1 day ago –
Tools for package owners.