matrix

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientLogout

func ClientLogout(ctx context.Context, accessToken string) error

ClientLogout invalidates the existing access token so that it cannot be used for authentication.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIErrorResponse

func ParseErrorResponse

func ParseErrorResponse(ctx context.Context, body []byte) *errors.MatrixAPIErrorResponse

ParseErrorResponse parses the response body into a new MatrixAPIErrorResponse object.

Types

type AdminCreateUserResponse

type AdminCreateUserResponse struct {
	AccessToken string `json:"access_token"`
	UserID      string `json:"user_id"`
	HomeServer  string `json:"home_server"`
	DeviceID    string `json:"device_id"`
}

AdminCreateUserResponse represents the response from a create user request by an administrator.

func AdminCreateUser

func AdminCreateUser(ctx context.Context, entry app.UserEntry, accessToken string) (*AdminCreateUserResponse, error)

AdminCreateUser uses an administrator access token to create a new user.

If the user already exists, a nil response and error are returned.

This function should only be called by the "setup" command as the registration secret may not be properly set otherwise.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type AdminGetNonceResponse

type AdminGetNonceResponse struct {
	Nonce string `json:"nonce"`
}

AdminGetNonceResponse represents the response from a get nonce request by an administrator.

type AdminJoinRoomResponse

type AdminJoinRoomResponse struct {
	RoomID string `json:"room_id"`
}

AdminJoinRoomResponse represents the response from a join user to room request by an administrator.

func AdminJoinUserToRoom

func AdminJoinUserToRoom(ctx context.Context, userID, roomID, accessToken string) (*AdminJoinRoomResponse, error)

AdminJoinUserToRoom joins the given user ID to the given room ID using an administrator access token.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type AdminListRoomResponse

type AdminListRoomResponse struct {
	RoomID             string `json:"room_id"`
	Name               string `json:"name"`
	CanonicalAlias     string `json:"canonical_alias"`
	JoinedMembers      int    `json:"joined_members"`
	JoinedLocalMembers int    `json:"joined_local_members"`
	Creator            string `json:"creator"`
	Public             bool   `json:"public"`
	JoinRules          string `json:"join_rules"`
}

AdminListRoomResponse represents a single room returned from a list rooms request by an administrator.

func AdminGetRoom

func AdminGetRoom(ctx context.Context, name, accessToken string) (*AdminListRoomResponse, error)

AdminGetRoom attempts to locate the room with the given name and return it.

If the room was not found, no error is returned and the room response is also nil.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

func AdminListRooms

func AdminListRooms(ctx context.Context, filter, accessToken string) ([]AdminListRoomResponse, error)

AdminListRooms uses an admin access token to list all of the rooms matching the given filter.

If an empty filter is provided, all rooms are returned.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type AdminListRoomsResponse

type AdminListRoomsResponse struct {
	Rooms      []AdminListRoomResponse `json:"rooms"`
	Offset     int                     `json:"offset"`
	NextBatch  *int                    `json:"next_batch"`
	TotalRooms int                     `json:"total_rooms"`
}

AdminListRoomsResponse represents all of the rooms returned from a list rooms request by an administrator.

type AdminListUserResponse

type AdminListUserResponse struct {
	Name              string `json:"name"`
	DisplayName       string `json:"displayname"`
	Admin             int    `json:"admin"`
	Deactivated       int    `json:"deactivated"`
	ShadowBanned      bool   `json:"shadow_banned"`
	PasswordHash      string `json:"password_hash"`
	CreationTimestamp uint64 `json:"creation_ts"`
}

AdminListUserResponse represents a single user returned from a list users request by an administrator.

func AdminGetUser

func AdminGetUser(ctx context.Context, name, accessToken string) (*AdminListUserResponse, error)

AdminGetUser uses an administrator access token to retrieve information about the specific user.

If the user was not found, a nil response and error are returned.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

func AdminListUsers

func AdminListUsers(ctx context.Context, filter, accessToken string) ([]AdminListUserResponse, error)

AdminListUsers uses an admin access token to list all of the users with a name or ID matching the given filter.

If an empty filter is provided, all rooms are returned.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type AdminListUsersResponse

type AdminListUsersResponse struct {
	Users     []AdminListUserResponse `json:"users"`
	NextToken *string                 `json:"next_token"`
	Total     int                     `json:"total"`
}

AdminListUsersResponse represents all of the users returned from a list users request by an administrator.

type AdminLoginAsUserResponse

type AdminLoginAsUserResponse struct {
	AccessToken string `json:"access_token"`
}

AdminLoginAsUserResponse represents the response return from a login as user request by an admin.

func AdminLoginAsUser

func AdminLoginAsUser(ctx context.Context, userID, accessToken string) (*AdminLoginAsUserResponse, error)

AdminLoginAsUser allows an admin to "assume" a user role using the returned access token.

Be sure to call the ClientLogout() function to invalidate the access token when you are finished.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type ClientCreatePublicRoomResponse

type ClientCreatePublicRoomResponse struct {
	RoomID string `json:"room_id"`
}

ClientCreatePublicRoomResponse represents the response returned from a client request to create a room.

func ClientCreatePublicRoom

func ClientCreatePublicRoom(ctx context.Context, name string, accessToken string) (
	*ClientCreatePublicRoomResponse, error)

ClientCreatePublicRoom creates the given room if it doesn't already exist.

If the room already exists, a nil response and error are returned.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type ClientJoinRoomResponse

type ClientJoinRoomResponse struct {
	RoomID string `json:"room_id"`
}

ClientJoinRoomResponse represents the response returned from a client request to join a room.

func ClientJoinRoom

func ClientJoinRoom(ctx context.Context, roomID, accessToken string) (*ClientJoinRoomResponse, error)

ClientJoinRoom joins the given room using the user's access token.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type ClientListPublicRoomResponse

type ClientListPublicRoomResponse struct {
	Aliases          []string `json:"aliases"`
	CanonicalAlias   string   `json:"canonical_alias"`
	Name             string   `json:"name"`
	NumJoinedMembers int      `json:"num_joined_members"`
	RoomID           string   `json:"room_id"`
	Topic            string   `json:"topic"`
	WorldReadable    bool     `json:"world_readable"`
	GuestCanJoin     bool     `json:"guest_can_join"`
	AvatarURL        string   `json:"avatar_url"`
}

ClientListRoomResponse represents a single room returned from a list public rooms request.

func ClientGetPublicRoom

func ClientGetPublicRoom(ctx context.Context, name, accessToken string) (*ClientListPublicRoomResponse, error)

ClientGetPublicRoom attempts to locate the room with the given name and return it.

If the room was not found, no error is returned and the room response is also nil.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

func ClientListPublicRooms

func ClientListPublicRooms(ctx context.Context, filter, accessToken string) ([]ClientListPublicRoomResponse, error)

ClientListPublicRooms list all of the public rooms matching the given filter.

If an empty filter is provided, all rooms are returned.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type ClientListPublicRoomsResponse

type ClientListPublicRoomsResponse struct {
	Rooms                  []ClientListPublicRoomResponse `json:"chunk"`
	NextBatch              *string                        `json:"next_batch"`
	PrevBatch              *string                        `json:"prev_batch"`
	TotalRoomCountEstimate int                            `json:"total_room_count_estimate"`
}

AdminListRoomsResponse represents all of the rooms returned from a list rooms request by an administrator.

type ClientLoginResponse

type ClientLoginResponse struct {
	AccessToken string `json:"access_token"`
	HomeServer  string `json:"home_server"`
	UserID      string `json:"user_id"`
}

ClientLoginResponse represents the response returned from a client login request.

func ClientPasswordLogin

func ClientPasswordLogin(ctx context.Context, username, password string) (*ClientLoginResponse, error)

ClientPasswordLogin attempts to perform password-based authentication to the Matrix server using the given credentials.

Be sure to call the ClientLogout() function to invalidate the access token when you are finished.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type ClientPostToRoomResponse

type ClientPostToRoomResponse struct {
	EventID string `json:"event_id"`
}

ClientPostToRoomResponse holds the response from API calls to post messages, files, etc. to a room.

func ClientPostFileToRoom

func ClientPostFileToRoom(ctx context.Context, roomID, url, filename, mimeType string, size int64,
	accessToken string) (*ClientPostToRoomResponse, error)

ClientPostFileToRoom posts a file to the given room.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

func ClientPostTextMessageToRoom

func ClientPostTextMessageToRoom(ctx context.Context, roomID, message, accessToken string) (
	*ClientPostToRoomResponse, error)

ClientPostTextMessageToRoom posts a plain text message to the given room.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type ServerVersionResponse

type ServerVersionResponse struct {
	PythonVersion string `json:"python_version"`
	ServerVersion string `json:"server_version"`
}

ServerVersionResponse represents a response from a request to get the server version.

func GetServerVersion

func GetServerVersion(ctx context.Context) (*ServerVersionResponse, error)

GetServerVersion returns information about the Matrix server.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

type UploadMediaResponse

type UploadMediaResponse struct {
	ContentURI string `json:"content_uri"`
}

UploadMediaResponse represents the response from uploading a file to the server.

func UploadMedia

func UploadMedia(ctx context.Context, contentType, filename, accessToken string, contents []byte) (
	*UploadMediaResponse, error)

UploadMedia uploads a file to the Matrix server.

The following errors are returned by this function: MatrixAPIRequestFailure, MatrixAPIResponseFailure, MatrixAPIErrorResponse

Jump to

Keyboard shortcuts

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