Documentation ¶
Index ¶
- Variables
- func NextTransactionID() string
- type Client
- func (c *Client) AvatarURL(userID matrix.UserID) (*matrix.URL, error)
- func (c *Client) AvatarURLSet(avatarURL matrix.URL) error
- func (c *Client) Ban(roomID matrix.RoomID, userID matrix.UserID, reason string) error
- func (c *Client) ClientConfig(configType string, v interface{}) error
- func (c *Client) ClientConfigRoom(roomID matrix.RoomID, configType string, v interface{}) error
- func (c *Client) ClientConfigRoomSet(roomID matrix.RoomID, configType string, config interface{}) error
- func (c *Client) ClientConfigSet(configType string, config interface{}) error
- func (c *Client) DMRooms() (event.DirectEvent, error)
- func (c *Client) DMRoomsSet(newRooms event.DirectEvent) error
- func (c *Client) DeactivateAccount(idServer string) (InteractiveDeactivate, error)
- func (c *Client) DiscoveryInfo() (*DiscoveryInfoResponse, error)
- func (c *Client) DisplayName(userID matrix.UserID) (*string, error)
- func (c *Client) DisplayNameSet(displayName string) error
- func (c *Client) Filter(filterID string) (*event.GlobalFilter, error)
- func (c *Client) FilterAdd(filterToUpload event.GlobalFilter) (string, error)
- func (c *Client) GetLoginMethods() ([]matrix.LoginMethod, error)
- func (c *Client) IgnoredUsers() ([]matrix.UserID, error)
- func (c *Client) IgnoredUsersSet(newList []matrix.UserID) error
- func (c *Client) Invite(roomID matrix.RoomID, userID matrix.UserID) error
- func (c *Client) Kick(roomID matrix.RoomID, userID matrix.UserID, reason string) error
- func (c *Client) Login(arg LoginArg) error
- func (c *Client) Logout() error
- func (c *Client) LogoutAll() error
- func (c *Client) MediaConfig() (MediaConfig, error)
- func (c *Client) MediaDownloadURL(matrixURL matrix.URL, allowRemote bool, filename string) (string, error)
- func (c *Client) MediaThumbnailURL(matrixURL matrix.URL, allowRemote bool, width int, height int, ...) (string, error)
- func (c *Client) MediaUpload(contentType string, filename string, body io.ReadCloser) (matrix.URL, error)
- func (c *Client) PasswordChange(newPassword string, logoutDevices bool) (*UserInteractiveAuthAPI, error)
- func (c *Client) Presence(userID matrix.UserID) (Presence, error)
- func (c *Client) PresenceSet(presence matrix.Presence, statusMsg string) error
- func (c *Client) PreviewURL(url string, ts matrix.Timestamp) (map[string]interface{}, error)
- func (c *Client) PublicRooms(limit int, since string, server string) (PublicRoomsResponse, error)
- func (c *Client) PublicRoomsSearch(arg PublicRoomsSearchArg) (PublicRoomsResponse, error)
- func (c *Client) ReceiptMarkerUpdate(roomID matrix.RoomID, receiptType ReceiptType, eventID matrix.EventID) error
- func (c *Client) Register(kind string, req RegisterArg) (InteractiveRegister, error)
- func (c *Client) RoomAlias(alias string) (RoomAliasResponse, error)
- func (c *Client) RoomAliasCreate(alias string, roomID matrix.RoomID) error
- func (c *Client) RoomAliasDelete(alias string) error
- func (c *Client) RoomAliases(roomID matrix.RoomID) ([]string, error)
- func (c *Client) RoomCreate(arg RoomCreateArg) (matrix.RoomID, error)
- func (c *Client) RoomEvent(roomID matrix.RoomID, eventID matrix.EventID) (event.RawEvent, error)
- func (c *Client) RoomEventRedact(roomID matrix.RoomID, eventID matrix.EventID, reason string) (matrix.EventID, error)
- func (c *Client) RoomEventSend(roomID matrix.RoomID, eventType event.Type, body interface{}) (matrix.EventID, error)
- func (c *Client) RoomForget(roomID matrix.RoomID) error
- func (c *Client) RoomJoin(roomID matrix.RoomID) error
- func (c *Client) RoomJoinedMembers(roomID matrix.RoomID) (map[matrix.UserID]RoomMember, error)
- func (c *Client) RoomLeave(roomID matrix.RoomID) error
- func (c *Client) RoomMembers(roomID matrix.RoomID, filter RoomMemberFilter) ([]event.RawEvent, error)
- func (c *Client) RoomMessages(roomID matrix.RoomID, query RoomMessagesQuery) (RoomMessagesResponse, error)
- func (c *Client) RoomState(roomID matrix.RoomID, eventType event.Type, key string) (*event.RawEvent, error)
- func (c *Client) RoomStateSend(roomID matrix.RoomID, event RoomStateSendArg) (matrix.EventID, error)
- func (c *Client) RoomStates(roomID matrix.RoomID) ([]event.RawEvent, error)
- func (c *Client) RoomVisibility(roomID matrix.RoomID) (RoomVisibility, error)
- func (c *Client) RoomVisibilitySet(roomID matrix.RoomID, newVisibility RoomVisibility) error
- func (c *Client) Rooms() ([]matrix.RoomID, error)
- func (c *Client) SendToDevice(eventType event.Type, messages DeviceMessages) error
- func (c *Client) ServerCapabilities() (*matrix.Capabilities, error)
- func (c *Client) SupportedVersions() (SupportedVersionsResponse, error)
- func (c *Client) Sync(req SyncArg) (*SyncResponse, error)
- func (c *Client) TagAdd(roomID matrix.RoomID, name matrix.TagName, tagData matrix.Tag) error
- func (c *Client) TagDelete(roomID matrix.RoomID, name matrix.TagName) error
- func (c *Client) Tags(roomID matrix.RoomID) (map[matrix.TagName]matrix.Tag, error)
- func (c *Client) ThreePID() ([]ThirdpartyIdentifier, error)
- func (c *Client) ThreePIDAdd(clientSecret string, sessionID string) (*UserInteractiveAuthAPI, error)
- func (c *Client) ThreePIDBind(req ThreePIDBindArg) error
- func (c *Client) ThreePIDDelete(req ThreePIDDeleteArg) (matrix.IDServerUnbindResult, error)
- func (c *Client) ThreePIDUnbind(req ThreePIDUnbindArg) (matrix.IDServerUnbindResult, error)
- func (c *Client) TurnServers() (TurnServersResponse, error)
- func (c *Client) TypingStart(roomID matrix.RoomID, timeout time.Duration) error
- func (c *Client) TypingStop(roomID matrix.RoomID) error
- func (c *Client) Unban(roomID matrix.RoomID, userID matrix.UserID) error
- func (c *Client) UpgradeRoom(roomID matrix.RoomID, newVersion string) (matrix.RoomID, error)
- func (c *Client) User(userID matrix.UserID) (User, error)
- func (c *Client) UserSearch(keyword string, limit int) (result []User, limited bool, err error)
- func (c *Client) UsernameAvailable(username string) (bool, error)
- func (c *Client) Whoami() (matrix.UserID, error)
- func (c Client) WithContext(ctx context.Context) *Client
- func (c Client) WithUserID(userID matrix.UserID) *Client
- type DeviceMessages
- type DiscoveryInfoResponse
- type InteractiveDeactivate
- type InteractiveRegister
- type LoginArg
- type MediaConfig
- type MediaThumbnailMethod
- type Presence
- type PublicRoom
- type PublicRoomsResponse
- type PublicRoomsSearchArg
- type PublicRoomsSearchFilter
- type ReceiptType
- type RegisterArg
- type RegisterResponse
- type RequestEmailTokenArg
- type RequestEmailTokenResponse
- type RequestPhoneTokenArg
- type RequestPhoneTokenResponse
- type RoomAliasResponse
- type RoomCreateArg
- type RoomCreateInvite
- type RoomMember
- type RoomMemberFilter
- type RoomMessagesDirection
- type RoomMessagesQuery
- type RoomMessagesResponse
- type RoomPreset
- type RoomStateSendArg
- type RoomVisibility
- type SupportedVersionsResponse
- type SyncArg
- type SyncDeviceLists
- type SyncEvents
- type SyncInvitedRoomEvents
- type SyncJoinedRoomEvents
- type SyncLeftRoomEvents
- type SyncResponse
- type SyncRoomEvents
- type SyncRoomSummary
- type SyncTimeline
- type ThirdpartyIdentifier
- type ThreePIDBindArg
- type ThreePIDCreds
- type ThreePIDDeleteArg
- type ThreePIDUnbindArg
- type TurnServersResponse
- type User
- type UserInteractiveAuthAPI
- func (u *UserInteractiveAuthAPI) Auth(req interface{}) error
- func (u *UserInteractiveAuthAPI) AuthDummy() error
- func (u *UserInteractiveAuthAPI) AuthEmail(threePidCreds ThreePIDCreds) error
- func (u *UserInteractiveAuthAPI) AuthPassword(id matrix.Identifier, password string) error
- func (u *UserInteractiveAuthAPI) AuthPhone(threePidCreds ThreePIDCreds) error
- func (u *UserInteractiveAuthAPI) AuthRecaptcha(response string) error
- func (u *UserInteractiveAuthAPI) AuthToken(token, transactionID string) error
- func (u *UserInteractiveAuthAPI) IsComplete() bool
- func (u *UserInteractiveAuthAPI) RequestEmailToken(req RequestEmailTokenArg) (*RequestEmailTokenResponse, error)
- func (u *UserInteractiveAuthAPI) RequestPhoneToken(req RequestPhoneTokenArg) (*RequestPhoneTokenResponse, error)
- func (u *UserInteractiveAuthAPI) Result() (*json.RawMessage, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrServerNotFound represents a IGNORE or FAIL_PROMPT meaning that // more information should be requested. ErrServerNotFound = errors.New("server not found") // ErrDiscoveryFail represents a FAIL_ERROR meaning that the server is // Matrix-aware but has returned invalid data. // Matrix specs recommend clients to prompt the user for further action // in this case. ErrDiscoveryFail = errors.New("auto-discovery failed") )
Errors returned by (*Client).DiscoveryInfo.
var ( EndpointBase = "_matrix/client/" + Version EndpointSupportedVersions = "_matrix/client/versions" EndpointUser = func(id matrix.UserID) string { return EndpointBase + "/user/" + url.PathEscape(string(id)) } EndpointRoom = func(id matrix.RoomID) string { return EndpointBase + "/rooms/" + url.PathEscape(string(id)) } EndpointUserRoom = func(userID matrix.UserID, roomID matrix.RoomID) string { return EndpointUser(userID) + "/rooms/" + url.PathEscape(string(roomID)) } EndpointLogin = EndpointBase + "/login" EndpointLogout = EndpointBase + "/logout" EndpointLogoutAll = EndpointLogout + "/all" EndpointRegister = EndpointBase + "/register" EndpointRegisterAvailable = EndpointRegister + "/available" EndpointRegisterRequestToken = func(authType string) string { return EndpointRegister + "/" + authType + "/requestToken" } EndpointAccount = EndpointBase + "/account" EndpointAccountWhoami = EndpointAccount + "/whoami" EndpointAccountDeactivate = EndpointAccount + "/deactivate" EndpointAccountPassword = EndpointAccount + "/password" EndpointAccountPasswordRequestToken = func(authType string) string { return EndpointAccountPassword + "/" + authType + "/requestToken" } EndpointAccount3PID = EndpointAccount + "/3pid" EndpointAccount3PIDAdd = EndpointAccount3PID + "/add" EndpointAccount3PIDBind = EndpointAccount3PID + "/bind" EndpointAccount3PIDRequestToken = func(authType string) string { return EndpointAccount3PID + "/" + authType + "/requestToken" } EndpointCapabilities = EndpointBase + "/capabilities" EndpointJoinedRooms = EndpointBase + "/joined_rooms" EndpointPublicRooms = EndpointBase + "/publicRooms" EndpointSync = EndpointBase + "/sync" EndpointFilter = func(userID matrix.UserID) string { return EndpointUser(userID) + "/filter" } EndpointFilterGet = func(userID matrix.UserID, filterID string) string { return EndpointFilter(userID) + "/" + url.PathEscape(filterID) } EndpointRoomCreate = EndpointBase + "/createRoom" EndpointRoomAliases = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/aliases" } EndpointRoomBan = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/ban" } EndpointRoomForget = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/forget" } EndpointRoomInvite = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/invite" } EndpointRoomJoin = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/join" } EndpointRoomJoinedMembers = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/joined_members" } EndpointRoomKick = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/kick" } EndpointRoomLeave = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/leave" } EndpointRoomMembers = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/members" } EndpointRoomMessages = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/messages" } EndpointRoomState = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/state" } EndpointRoomUnban = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/unban" } EndpointRoomUpgrade = func(roomID matrix.RoomID) string { return EndpointRoom(roomID) + "/upgrade" } EndpointRoomEvent = func(roomID matrix.RoomID, eventID matrix.EventID) string { return EndpointRoom(roomID) + "/event/" + url.PathEscape(string(eventID)) } EndpointRoomStateExact = func(roomID matrix.RoomID, eventType event.Type, stateKey string) string { return EndpointRoomState(roomID) + "/" + url.PathEscape(string(eventType)) + "/" + url.PathEscape(stateKey) } EndpointRoomReceipt = func(roomID matrix.RoomID, receiptType ReceiptType, eventID matrix.EventID) string { return EndpointRoomState(roomID) + "/" + url.PathEscape(string(receiptType)) + "/" + url.PathEscape(string(eventID)) } EndpointRoomRedact = func(roomID matrix.RoomID, eventID matrix.EventID, transactionID string) string { return EndpointRoom(roomID) + "/redact/" + url.PathEscape(string(eventID)) + "/" + url.PathEscape(transactionID) } EndpointRoomSend = func(roomID matrix.RoomID, eventType event.Type, transactionID string) string { return EndpointRoom(roomID) + "/send/" + url.PathEscape(string(eventType)) + "/" + url.PathEscape(transactionID) } EndpointRoomTyping = func(roomID matrix.RoomID, userID matrix.UserID) string { return EndpointRoom(roomID) + "/typing/" + url.PathEscape(string(userID)) } EndpointDirectory = EndpointBase + "/directory" EndpointDirectoryRoomAlias = func(roomAlias string) string { return EndpointDirectory + "/room/" + url.PathEscape(roomAlias) } EndpointDirectoryListRoom = func(roomID matrix.RoomID) string { return EndpointDirectory + "/list/room/" + url.PathEscape(string(roomID)) } EndpointUserDirectorySearch = EndpointBase + "/user_directory/search" EndpointProfile = func(userID matrix.UserID) string { return EndpointBase + "/profile/" + url.PathEscape(string(userID)) } EndpointProfileAvatarURL = func(userID matrix.UserID) string { return EndpointProfile(userID) + "/avatar_url" } EndpointProfileDisplayName = func(userID matrix.UserID) string { return EndpointProfile(userID) + "/displayname" } EndpointMedia = "_matrix/media/" + Version EndpointMediaConfig = EndpointMedia + "/config" EndpointMediaPreviewURL = EndpointMedia + "/preview_url" EndpointMediaUpload = EndpointMedia + "/upload" EndpointMediaDownload = func(serverName string, mediaID string, fileName string) string { return EndpointMedia + "/download/" + url.PathEscape(serverName) + "/" + url.PathEscape(mediaID) + "/" + url.PathEscape(fileName) } EndpointMediaThumbnail = func(serverName string, mediaID string) string { return EndpointMedia + "/thumbnail/" + url.PathEscape(serverName) + "/" + url.PathEscape(mediaID) } EndpointVOIPTurnServers = EndpointMedia + "/voip/turnServer" EndpointPresenceStatus = func(userID matrix.UserID) string { return EndpointBase + "/presence/" + url.PathEscape(string(userID)) + "/status" } EndpointAccountDataGlobal = func(userID matrix.UserID, dataType string) string { return EndpointUser(userID) + "/account_data/" + url.PathEscape(dataType) } EndpointAccountDataRoom = func(userID matrix.UserID, roomID matrix.RoomID, dataType string) string { return EndpointUserRoom(userID, roomID) + "/account_data/" + url.PathEscape(dataType) } EndpointSendToDevice = func(eventType event.Type, transactionID string) string { return EndpointBase + "/sendToDevice/" + url.PathEscape(string(eventType)) + "/" + url.PathEscape(transactionID) } EndpointTags = func(userID matrix.UserID, roomID matrix.RoomID) string { return EndpointUserRoom(userID, roomID) + "/tags" } EndpointTag = func(userID matrix.UserID, roomID matrix.RoomID, name matrix.TagName) string { return EndpointTags(userID, roomID) + "/" + url.PathEscape(string(name)) } EndpointSSOLogin = func(redirectURL string) string { return EndpointBase + "/login/sso/redirect?redirectUrl=" + url.QueryEscape(redirectURL) } )
Known Matrix Client-Server API endpoints.
var ErrInteractiveAuthIncomplete = errors.New("interactive auth has not been completed yet")
ErrInteractiveAuthIncomplete is returned when the result is requested before interactive auth is complete.
var ErrInvalidTagName = errors.New("tag name must not exceed 255 bytes")
var ErrUnsupportedAuthType = errors.New("3PID tokens are unsupported by the current interactive auth session")
ErrUnsupportedAuthType is returned when a 3PID auth is attempted on an endpoint that doesn't support it.
var Version = "r0"
Version is the Client-Server API version implemented by Gotrix.
Functions ¶
func NextTransactionID ¶
func NextTransactionID() string
NextTransactionID retrieves the next transaction ID to use.
Types ¶
type Client ¶
type Client struct { httputil.Client IdentityServer string UserID matrix.UserID DeviceID matrix.DeviceID }
Client represents a session that can be established to the server. It contains every info the server expects to be persisted on client-side.
For routes expecting user ID, the UserID field is used unless otherwise provided.
func (*Client) AvatarURLSet ¶ added in v0.3.0
AvatarURLSet sets the avatar URL of the provided user.
func (*Client) ClientConfig ¶ added in v0.3.0
ClientConfig retrieves the client config previously stored with ClientConfigSet. 'v' is a pointer that is directly passed into json.Unmarshal to unmarshal the content of the config.
func (*Client) ClientConfigRoom ¶ added in v0.3.0
ClientConfigRoom retrieves the client config previously stored with ClientConfigRoomSet. 'v' is a pointer that is directly passed into json.Unmarshal to unmarshal the content of the config.
func (*Client) ClientConfigRoomSet ¶ added in v0.3.0
func (c *Client) ClientConfigRoomSet(roomID matrix.RoomID, configType string, config interface{}) error
ClientConfigRoomSet sets the client config to the provided value. It is equivalent to ClientConfigSet except it is scoped to a Matrix room. 'configType' should be namespaced Java-style (com.example.someData) to prevent clashes. 'config' is JSON-encoded before sent to the server.
The provided config will be provided as an event with type 'configType' and content 'config' in AccountData of rooms in SyncResponse.
func (*Client) ClientConfigSet ¶ added in v0.3.0
ClientConfigSet sets the client config to the provided value. 'configType' should be namespaced Java-style (com.example.someData) to prevent clashes. 'config' is JSON-encoded before sent to the server.
The provided config will be provided as an event with type 'configType' and content 'config' in AccountData of SyncResponse.
func (*Client) DMRooms ¶ added in v0.3.0
func (c *Client) DMRooms() (event.DirectEvent, error)
DMRooms fetches the list of DM rooms as saved in 'm.direct'.
func (*Client) DMRoomsSet ¶ added in v0.3.0
func (c *Client) DMRoomsSet(newRooms event.DirectEvent) error
DMRoomsSet updates the DM rooms saved in 'm.direct'.
func (*Client) DeactivateAccount ¶
func (c *Client) DeactivateAccount(idServer string) (InteractiveDeactivate, error)
DeactivateAccount deactivates the account of the current user.
idServer is the identity server to unbind all of the user's 3PID from. It is optional and if not provided, the homeserver is responsible for determining the unbind source.
It returns an InteractiveDeactivate object which should be used to interactively fulfill authentication requirements of the server.
func (*Client) DiscoveryInfo ¶
func (c *Client) DiscoveryInfo() (*DiscoveryInfoResponse, error)
DiscoveryInfo discovers homeserver and identity server from the URL set in (*Client).HomeServer and validates them.
It implements https://matrix.org/docs/spec/client_server/r0.6.1#well-known-uri.
func (*Client) DisplayName ¶ added in v0.3.0
DisplayName returns the display name of the provided user.
func (*Client) DisplayNameSet ¶ added in v0.3.0
DisplayNameSet sets the display name of the provided user.
func (*Client) Filter ¶
func (c *Client) Filter(filterID string) (*event.GlobalFilter, error)
Filter downloads the requested filter from the homeserver.
func (*Client) FilterAdd ¶
func (c *Client) FilterAdd(filterToUpload event.GlobalFilter) (string, error)
FilterAdd uploads the provided filter to the homeserver and returns its assigned ID.
func (*Client) GetLoginMethods ¶
func (c *Client) GetLoginMethods() ([]matrix.LoginMethod, error)
GetLoginMethods return the login methods supported by the homeserver.
func (*Client) IgnoredUsers ¶ added in v0.3.0
IgnoredUsers returns the list of users configured to be ignored.
func (*Client) IgnoredUsersSet ¶ added in v0.3.0
IgnoredUsersSet sets the list of users configured to be ignored.
func (*Client) Logout ¶
Logout clears the AccessToken field in the client and attempts to invalidate the token on the server-side.
func (*Client) LogoutAll ¶
LogoutAll clears the AccessToken field in the client and attempts to invalidate all tokens on the server-side.
func (*Client) MediaConfig ¶ added in v0.2.0
func (c *Client) MediaConfig() (MediaConfig, error)
MediaConfig requests the media configuration of the server. Clients should follow the guide when using content repository endpoints.
func (*Client) MediaDownloadURL ¶ added in v0.2.0
func (c *Client) MediaDownloadURL(matrixURL matrix.URL, allowRemote bool, filename string) (string, error)
MediaDownloadURL returns the HTTP URL for the provided matrix URL. If allowRemote is false, the server will not attempt to fetch the media if it is deemed remote.
func (*Client) MediaThumbnailURL ¶ added in v0.2.0
func (c *Client) MediaThumbnailURL(matrixURL matrix.URL, allowRemote bool, width int, height int, method MediaThumbnailMethod) (string, error)
MediaThumbnailURL returns the HTTP URL for the provided matrix URL. If allowRemote is false, the server will not attempt to fetch the media if it is deemed remote. The provided width and height are treated as a guideline and the actual thumbnail may be a different size.
func (*Client) MediaUpload ¶ added in v0.2.0
func (c *Client) MediaUpload(contentType string, filename string, body io.ReadCloser) (matrix.URL, error)
MediaUpload uploads the provided file to the Matrix homeserver.
func (*Client) PasswordChange ¶
func (c *Client) PasswordChange(newPassword string, logoutDevices bool) (*UserInteractiveAuthAPI, error)
PasswordChange sends a request to the homeserver to change the password. All devices except the current one will be logged out if logoutDevices is set to true.
func (*Client) PresenceSet ¶ added in v0.3.0
PresenceSet sets the presence of the current user to the provided presence and status message.
func (*Client) PreviewURL ¶ added in v0.2.0
PreviewURL requests the homeserver to generate a preview of the provided URL. It should be handled with care especially in an encrypted channel to prevent leaking URLs. ts is the preferred point in time to return a preview for. If it's zero value, the constraint is not passed on.
The returned map is a map of OpenGraph info. og:image will be an MXC URI to the image instead if available.
func (*Client) PublicRooms ¶ added in v0.3.0
PublicRooms list all the public rooms advertised by a server. All parameters are optional. 'since' should be a token returned in PublicRoomsResponse. 'server' defaults to the homeserver if it is an empty string.
func (*Client) PublicRoomsSearch ¶ added in v0.3.0
func (c *Client) PublicRoomsSearch(arg PublicRoomsSearchArg) (PublicRoomsResponse, error)
PublicRoomsSearch is equivalent to PublicRooms except it allows the user to provide filters to narrow search result.
func (*Client) ReceiptMarkerUpdate ¶ added in v0.3.0
func (c *Client) ReceiptMarkerUpdate(roomID matrix.RoomID, receiptType ReceiptType, eventID matrix.EventID) error
ReceiptMarkerUpdate updates the location of receipt marker to the event ID specified.
func (*Client) Register ¶
func (c *Client) Register(kind string, req RegisterArg) (InteractiveRegister, error)
Register registers an account on the homeserver with the provided arguments. Once the authentication is successful, the client is automatically logged in if InhibitLogin is set to false in RegisterArg.
It returns an InteractiveRegister object which should be used to interactively fulfill authentication requirements of the server.
func (*Client) RoomAlias ¶
func (c *Client) RoomAlias(alias string) (RoomAliasResponse, error)
RoomAlias fetches information about a room alias.
func (*Client) RoomAliasCreate ¶
RoomAliasCreate creates a room alias.
func (*Client) RoomAliasDelete ¶
RoomAliasDelete deletes a room alias.
func (*Client) RoomAliases ¶
RoomAliases fetches all alias of a given room.
func (*Client) RoomCreate ¶
func (c *Client) RoomCreate(arg RoomCreateArg) (matrix.RoomID, error)
RoomCreate creates the room with the provided arguments.
Note: For backwards compatibility reasons, the default setting for history visibility is such that users can view all messages as long as they were a member at some point. This might be undesirable and the client should prompt the user to decide, sending RoomHistoryVisibilityEvent as necessary.
func (*Client) RoomEvent ¶
RoomEvent fetches an event from the server with the provided room ID or event ID.
func (*Client) RoomEventRedact ¶
func (c *Client) RoomEventRedact(roomID matrix.RoomID, eventID matrix.EventID, reason string) (matrix.EventID, error)
RoomEventRedact redacts a room event as specified by the room ID and event ID. A user can redact events they sent out or other people's event provided they have the power level to.
func (*Client) RoomEventSend ¶
func (c *Client) RoomEventSend(roomID matrix.RoomID, eventType event.Type, body interface{}) (matrix.EventID, error)
RoomEventSend sends the provided one-off event to the provided room ID.
func (*Client) RoomForget ¶
RoomForget tells the homeserver that the user no longer intend to fetch events from the provided room. This allows the homeserver to delete the room if every previous member forgets it. The client must not be in the room when RoomForget is called.
func (*Client) RoomJoinedMembers ¶
RoomJoinedMembers fetches all the joined members and return them as a map of user ID to room member.
func (*Client) RoomMembers ¶
func (c *Client) RoomMembers(roomID matrix.RoomID, filter RoomMemberFilter) ([]event.RawEvent, error)
RoomMembers fetches the member list for a room from the homeserver. The returned member list is in the form of an array of RoomMember events.
func (*Client) RoomMessages ¶
func (c *Client) RoomMessages(roomID matrix.RoomID, query RoomMessagesQuery) (RoomMessagesResponse, error)
RoomMessages fetches the messages specified in the query range and return them.
func (*Client) RoomState ¶
func (c *Client) RoomState(roomID matrix.RoomID, eventType event.Type, key string) (*event.RawEvent, error)
RoomState fetches the latest state event for the provided state in the provided room.
func (*Client) RoomStateSend ¶
func (c *Client) RoomStateSend(roomID matrix.RoomID, event RoomStateSendArg) (matrix.EventID, error)
RoomStateSend sends the provided state event to the provided room ID.
func (*Client) RoomStates ¶
RoomStates fetches all the current state events of the provided room. If the user has left the room, it returns the state before the user leaves.
func (*Client) RoomVisibility ¶ added in v0.3.0
func (c *Client) RoomVisibility(roomID matrix.RoomID) (RoomVisibility, error)
RoomVisibility returns the visibility of a room on the server's public room directory.
func (*Client) RoomVisibilitySet ¶ added in v0.3.0
func (c *Client) RoomVisibilitySet(roomID matrix.RoomID, newVisibility RoomVisibility) error
RoomVisibilitySet sets the visibility of a room on the server's public room directory.
func (*Client) SendToDevice ¶ added in v0.3.0
func (c *Client) SendToDevice(eventType event.Type, messages DeviceMessages) error
SendToDevice sends the provided event to the specified devices.
func (*Client) ServerCapabilities ¶
func (c *Client) ServerCapabilities() (*matrix.Capabilities, error)
ServerCapabilities retrieves the homeserver's capabilities.
func (*Client) SupportedVersions ¶
func (c *Client) SupportedVersions() (SupportedVersionsResponse, error)
SupportedVersions returns the list of versions supported by a homeserver.
The homeserver is inferred from (*Client).HomeServer and should be set before calling this function.
func (*Client) Sync ¶
func (c *Client) Sync(req SyncArg) (*SyncResponse, error)
Sync requests the latest state changes from the server.
func (*Client) ThreePID ¶
func (c *Client) ThreePID() ([]ThirdpartyIdentifier, error)
ThreePID returns all thirdparty identifiers associated with the current token.
func (*Client) ThreePIDAdd ¶
func (c *Client) ThreePIDAdd(clientSecret string, sessionID string) (*UserInteractiveAuthAPI, error)
ThreePIDAdd adds the third party identifier associated with the client secret and session ID to the current token.
func (*Client) ThreePIDBind ¶
func (c *Client) ThreePIDBind(req ThreePIDBindArg) error
ThreePIDBind binds a third party identifier connected to an identity server to the current token.
func (*Client) ThreePIDDelete ¶
func (c *Client) ThreePIDDelete(req ThreePIDDeleteArg) (matrix.IDServerUnbindResult, error)
ThreePIDDelete deletes a third party identifier from the current token.
func (*Client) ThreePIDUnbind ¶
func (c *Client) ThreePIDUnbind(req ThreePIDUnbindArg) (matrix.IDServerUnbindResult, error)
ThreePIDUnbind unbinds a third party identifier from the current token.
func (*Client) TurnServers ¶
func (c *Client) TurnServers() (TurnServersResponse, error)
TurnServers returns the list of TURN servers which clients can use to contact the remote party. It may error if the homeserver doesn't support the VoIP module or if the request failed.
func (*Client) TypingStart ¶ added in v0.3.0
TypingStart notifies the server that the user is typing in a specific room. It should be repeated while the user is typing with preferably a few seconds of safety margin from timeout.
func (*Client) TypingStop ¶ added in v0.3.0
TypingStop notifies the server that the user has stopped typing in a specific room.
func (*Client) UpgradeRoom ¶ added in v0.3.0
UpgradeRoom creates a new room linked to the specified room with the specified new version.
func (*Client) UserSearch ¶ added in v0.3.0
UserSearch searches for users that match the keyword. The default limit is 10 if the zero value is provided. 'limited' is true when the result is being limited by the provided limit.
func (*Client) UsernameAvailable ¶
UsernameAvailable returns if the username is reported as available on the homeserver.
Clients should be aware that this might be racey as registration can take place between UsernameAvailable() and actual registration.
func (*Client) Whoami ¶
Whoami queries the homeserver to check if the token is still valid. The user ID is returned if it's successful.
func (Client) WithContext ¶ added in v0.2.0
WithContext creates a copy of Client that uses the provided context when creating a HTTP request.
type DeviceMessages ¶ added in v0.3.0
DeviceMessages are a set of messages that can be sent through the SendToDevice function.
type DiscoveryInfoResponse ¶
type DiscoveryInfoResponse struct { HomeServer struct { BaseURL string `json:"base_url"` } `json:"m.homeserver"` IdentityServer struct { BaseURL string `json:"base_url"` } `json:"m.identity_server"` }
DiscoveryInfoResponse represents the response to (*Client).DiscoveryInfo.
type InteractiveDeactivate ¶
type InteractiveDeactivate struct {
*UserInteractiveAuthAPI
}
InteractiveDeactivate is a struct that adds response parsing helper functions onto UserInteractiveAuthAPI. To see functions on authenticating, refer to it instead.
func (InteractiveDeactivate) DeactivateResponse ¶
func (i InteractiveDeactivate) DeactivateResponse() (matrix.IDServerUnbindResult, error)
DeactivateResponse formats the Result() as the response of the deactivation. It returns an error if there isn't any result yet.
type InteractiveRegister ¶
type InteractiveRegister struct {
*UserInteractiveAuthAPI
}
InteractiveRegister is a struct that adds response parsing helper functions onto UserInteractiveAuthAPI. To see functions on authenticating, refer to it instead.
func (InteractiveRegister) RegisterResponse ¶
func (i InteractiveRegister) RegisterResponse() (*RegisterResponse, error)
RegisterResponse formats the Result() as a RegisterResponse. It returns an error if there isn't any result yet or the response is malformed.
type LoginArg ¶
type LoginArg struct { Type matrix.LoginMethod `json:"type"` InitialDeviceDisplayName string `json:"initial_device_display_name,omitempty"` // DeviceID should be provided when resuming a session. DeviceID matrix.DeviceID `json:"device_id,omitempty"` // Identifier and Password is only required when logging in with password. Identifier matrix.Identifier `json:"identifier,omitempty"` Password string `json:"password,omitempty"` // Token is only required when logging in with token. Token string `json:"token,omitempty"` }
LoginArg represents all possible login arguments.
type MediaConfig ¶ added in v0.2.0
type MediaConfig struct {
UploadSize int `json:"m.upload.size"`
}
MediaConfig is the configuration of the homeserver for media.
type MediaThumbnailMethod ¶ added in v0.2.0
type MediaThumbnailMethod string
MediaThumbnailMethod specifies the method the homeserver should crop the image in.
const ( MediaThumbnailScale MediaThumbnailMethod = "scale" MediaThumbnailCrop MediaThumbnailMethod = "crop" )
The two types of valid values for MediaThumbnailMethod are scale and crop.
type Presence ¶ added in v0.3.0
type Presence struct { Presence matrix.Presence `json:"presence"` LastActiveAgo *int `json:"last_active_ago,omitempty"` StatusMsg *string `json:"status_msg,omitempty"` CurrentlyActive *bool `json:"currently_active,omitempty"` }
Presence is the presence information of a user as returned by (*Client).Presence.
type PublicRoom ¶ added in v0.3.0
type PublicRoom struct { // Always provided. JoinedMemberCount int `json:"num_joined_members"` RoomID string `json:"room_id"` WorldReadable bool `json:"world_readable,omitempty"` GuestCanJoin bool `json:"guest_can_join,omitempty"` // Optional values. Aliases []string `json:"aliases"` AvatarURL *matrix.URL `json:"avatar_url,omitempty"` CanonicalAlias *string `json:"canonical_alias,omitempty"` Name *string `json:"name,omitempty"` Topic *string `json:"topic,omitempty"` }
PublicRoom is a room advertised by the server.
type PublicRoomsResponse ¶ added in v0.3.0
type PublicRoomsResponse struct { Chunk []PublicRoom `json:"chunk"` // Pagination token to fetch previous or next batch. PrevBatch *string `json:"prev_batch"` NextBatch *string `json:"next_batch"` TotalRoomCountEstimate *int `json:"total_room_count_estimate"` }
PublicRoomsResponse is the response to (*Client).PublicRooms.
type PublicRoomsSearchArg ¶ added in v0.3.0
type PublicRoomsSearchArg struct { Limit int `json:"-"` Since string `json:"-"` Server string `json:"-"` Filter *PublicRoomsSearchFilter `json:"filter,omitempty"` IncludeAllNetworks bool `json:"include_all_networks,omitempty"` ThirdPartyInstanceID string `json:"third_party_instance_id"` }
PublicRoomsSearchArg is the argument to (*Client).PublicRoomSearch.
type PublicRoomsSearchFilter ¶ added in v0.3.0
type PublicRoomsSearchFilter struct {
Keyword *string `json:"generic_search_term,omitempty"`
}
PublicRoomsSearchFilter is the filter applied to PublicRoomSearch.
type ReceiptType ¶ added in v0.3.0
type ReceiptType string
ReceiptType is the type of receipt. ReceiptRead is the only valid type.
const ReceiptRead ReceiptType = "m.read"
ReceiptRead acknowledges that the event has been read.
type RegisterArg ¶
type RegisterArg struct { Auth interface{} `json:"auth,omitempty"` Username string `json:"username"` Password string `json:"password"` DeviceID matrix.DeviceID `json:"device_id,omitempty"` InitialDeviceDisplayName string `json:"initial_device_display_name,omitempty"` InhibitLogin bool `json:"inhibit_login,omitempty"` }
RegisterArg represents arguments for the Register function.
type RegisterResponse ¶
type RegisterResponse struct { UserID matrix.UserID `json:"user_id"` AccessToken string `json:"access_token"` DeviceID matrix.DeviceID `json:"device_id"` }
RegisterResponse represents the success response from the register endpoint.
type RequestEmailTokenArg ¶
type RequestEmailTokenArg struct { ClientSecret string `json:"client_secret"` Email string `json:"email"` SendAttempt int `json:"send_attempt"` NextLink string `json:"next_link,omitempty"` IDServer string `json:"id_server,omitempty"` IDAccessToken string `json:"id_access_token,omitempty"` }
RequestEmailTokenArg represents all possible argument to RequestEmailToken.
type RequestEmailTokenResponse ¶
type RequestEmailTokenResponse struct { SessionID string `json:"sid"` SubmitURL string `json:"submit_url"` }
RequestEmailTokenResponse represents the response to (*UserInteractiveAuthAPI).RequestEmailToken.
type RequestPhoneTokenArg ¶
type RequestPhoneTokenArg struct { ClientSecret string `json:"client_secret"` PhoneNumber string `json:"phone_number"` SendAttempt int `json:"send_attempt"` NextLink string `json:"next_link,omitempty"` IDServer string `json:"id_server,omitempty"` IDAccessToken string `json:"id_access_token,omitempty"` }
RequestPhoneTokenArg represents all possible argument to RequestPhoneToken.
type RequestPhoneTokenResponse ¶
type RequestPhoneTokenResponse struct { SessionID string `json:"sid"` SubmitURL string `json:"submit_url"` }
RequestPhoneTokenResponse represents the response to (*UserInteractiveAuthAPI).RequestPhoneToken.
type RoomAliasResponse ¶
type RoomAliasResponse struct { RoomID matrix.RoomID `json:"room_id"` Servers []string `json:"servers"` // A list of servers that are aware of this room alias. }
RoomAliasResponse represents the response to (*Client).RoomAlias.
type RoomCreateArg ¶
type RoomCreateArg struct { Visibility RoomVisibility `json:"visibility,omitempty"` AliasName string `json:"room_alias_name,omitempty"` // Desired local part of room alias Name string `json:"name,omitempty"` // The displayed name Topic string `json:"topic,omitempty"` // The displayed topic Invite []matrix.UserID `json:"invite,omitempty"` // A list of users to invite ThirdpartyInvite []RoomCreateInvite `json:"invite_3pid,omitempty"` // List of third party invites Version string `json:"room_version,omitempty"` // Room Version InitialState []event.Event `json:"initial_state,omitempty"` // Initial State Preset RoomPreset `json:"preset,omitempty"` // The preset to use for permissions. IsDirectMessage bool `json:"is_direct,omitempty"` // True if this should be a Direct Message // Extra keys to add to the RoomCreate event. CreationContent map[string]interface{} `json:"creation_content,omitempty"` PowerLevelOverride *event.RoomPowerLevelsEvent `json:"power_level_content_override,omitempty"` }
RoomCreateArg represents all arguments to (*Client).RoomCreate.
type RoomCreateInvite ¶
type RoomCreateInvite struct { IdentityServer string `json:"id_server"` // Identity server to lookup on AccessToken string `json:"id_access_token"` // Access token previously registered with identity server Medium string `json:"medium"` // The kind being looked up like "email". Address string `json:"address"` // The third party identifier to look up. }
RoomCreateInvite represents information to identify a third party user to invite.
type RoomMember ¶
type RoomMember struct { DisplayName string `json:"display_name"` AvatarURL matrix.URL `json:"avatar_url"` }
RoomMember represents a member in a room as returned by (*Client).RoomJoinedMembers.
type RoomMemberFilter ¶
type RoomMemberFilter struct { // The pagination token to query at. At string `json:"at,omitempty"` Membership event.MemberType `json:"membership,omitempty"` NotMembership event.MemberType `json:"not_membership,omitempty"` }
RoomMemberFilter represents a filter that can be set to filter a RoomMembers request.
type RoomMessagesDirection ¶
type RoomMessagesDirection string
RoomMessagesDirection specifies the direction to fetch in.
const ( // RoomMessagesForward fetches newer messages. RoomMessagesForward RoomMessagesDirection = "f" // RoomMessagesBackward fetches older messages. RoomMessagesBackward RoomMessagesDirection = "b" )
type RoomMessagesQuery ¶
type RoomMessagesQuery struct { From string // Required Direction RoomMessagesDirection // Required To string Limit int Filter *event.RoomEventFilter }
RoomMessagesQuery represents the query the client should send to the homeserver.
type RoomMessagesResponse ¶
type RoomMessagesResponse struct { Start string `json:"start"` // The token pagination starts from. End string `json:"end"` // The token pagination ends on. Chunk []event.RawEvent `json:"chunk"` // A list of room events. State []event.RawEvent `json:"state"` // A list of state events relevant to the room events. }
RoomMessagesResponse represents the response to (*Client).RoomMessages.
type RoomPreset ¶
type RoomPreset string
RoomPreset is the preset of room settings that can be used for sane defaults.
const ( // PresetTrustedPrivateChat gives everyone admin practically. PresetTrustedPrivateChat RoomPreset = "trusted_private_chat" // PresetPrivateChat makes the room invite-only. PresetPrivateChat RoomPreset = "private_chat" // PresetPublicChat mandates account creation to view the room. PresetPublicChat RoomPreset = "public_chat" )
type RoomStateSendArg ¶
RoomStateSendArg represents all required arguments to (*Client).RoomStateSend.
type RoomVisibility ¶ added in v0.3.0
type RoomVisibility string
RoomVisibility represents the initial visibility of the room.
const ( // RoomPublic will publish the room into the published room list. RoomPublic RoomVisibility = "public" // RoomPrivate will NOT publish the room into the published room list. RoomPrivate RoomVisibility = "private" )
type SupportedVersionsResponse ¶
type SupportedVersionsResponse struct { Versions []string `json:"versions"` UnstableFeatures map[string]bool `json:"unstable_features"` }
SupportedVersionsResponse represents the response to (*Client).SupportedVersions.
type SyncArg ¶
type SyncArg struct { Filter string `json:"filter,omitempty"` Since string `json:"since,omitempty"` FullState bool `json:"full_state,omitempty"` NewPresence matrix.Presence `json:"set_presence,omitempty"` Timeout int `json:"timeout,omitempty"` }
SyncArg represents all possible arguments that can be provided to a sync API call.
type SyncDeviceLists ¶
SyncDeviceLists is a list of users who has their encryption keys changed (added or modified) or deleted (Left).
type SyncEvents ¶
SyncEvents are a list of events.
type SyncInvitedRoomEvents ¶
type SyncInvitedRoomEvents struct { State struct { Events []event.StrippedEvent `json:"events,omitempty"` } `json:"invite_state,omitempty"` }
SyncInvitedRoomEvents consists of events that are tied to rooms that the client is invited to.
type SyncJoinedRoomEvents ¶
type SyncJoinedRoomEvents struct { Summary SyncRoomSummary `json:"summary,omitempty"` State SyncEvents `json:"state,omitempty"` Timeline SyncTimeline `json:"timeline,omitempty"` Ephemeral SyncEvents `json:"ephemeral,omitempty"` AccountData SyncEvents `json:"account_data,omitempty"` UnreadCount struct { Highlight int `json:"highlight_count,omitempty"` Notification int `json:"notification_count,omitempty"` } `json:"unread_notifications,omitempty"` }
SyncJoinedRoomEvents consists of events that are tied to joined rooms (rooms the user is in).
type SyncLeftRoomEvents ¶
type SyncLeftRoomEvents struct { State SyncEvents `json:"state,omitempty"` Timeline SyncTimeline `json:"timeline,omitempty"` AccountData SyncEvents `json:"account_data,omitempty"` }
SyncLeftRoomEvents consists of events that are tied to rooms that the user has left.
type SyncResponse ¶
type SyncResponse struct { NextBatch string `json:"next_batch"` Presence SyncEvents `json:"presence,omitempty"` AccountData SyncEvents `json:"account_data,omitempty"` Rooms SyncRoomEvents `json:"rooms,omitempty"` ToDevice SyncEvents `json:"to_device,omitempty"` DeviceLists SyncDeviceLists `json:"device_lists,omitempty"` DeviceOneTimeKeysCount map[string]int `json:"device_one_time_keys_count,omitempty"` }
SyncResponse represents the response of a sync API call consisting of every info the server updates the client on.
type SyncRoomEvents ¶
type SyncRoomEvents struct { Joined map[matrix.RoomID]SyncJoinedRoomEvents `json:"join,omitempty"` Invited map[matrix.RoomID]SyncInvitedRoomEvents `json:"invite,omitempty"` Left map[matrix.RoomID]SyncLeftRoomEvents `json:"leave,omitempty"` }
SyncRoomEvents consists of events that are tied to specific rooms (like messages and typing notifications).
type SyncRoomSummary ¶
type SyncRoomSummary struct { Heroes []matrix.UserID `json:"m.heroes,omitempty"` JoinedCount int `json:"m.joined_member_count,omitempty"` InvitedCount int `json:"m.invited_member_count,omitempty"` }
SyncRoomSummary consists of data that the client may need to render a room correctly.
Heroes are users that are allowed to set a name/canonical alias to a room.
type SyncTimeline ¶
type SyncTimeline struct { Events []event.RawEvent `json:"events,omitempty"` Limited bool `json:"limited,omitempty"` PreviousBatch string `json:"prev_batch"` }
SyncTimeline consists of a timeline of events.
If limited is true, the query is limited by the filter limits set and the client should query if desired.
PreviousBatch can be used as an ID to index into previous timeline events.
type ThirdpartyIdentifier ¶
type ThirdpartyIdentifier struct { Medium string `json:"medium"` Address string `json:"address"` ValidatedAt matrix.Timestamp `json:"validated_at"` AddedAt matrix.Timestamp `json:"added_at"` }
ThirdpartyIdentifier is an instance of thirdparty identifier returned by the homeserver.
type ThreePIDBindArg ¶
type ThreePIDBindArg struct { ClientSecret string `json:"client_secret"` IDServer string `json:"id_server"` IDAccessToken string `json:"id_access_token"` SessionID string `json:"sid"` }
ThreePIDBindArg represents all required arguments of (*Client).ThreePIDBind.
type ThreePIDCreds ¶
type ThreePIDCreds struct { IdentitySessionID string `json:"sid"` ClientSecret string `json:"client_secret"` IdentityServerURL string `json:"id_server"` IdentityAccessToken string `json:"id_access_token"` }
ThreePIDCreds represents three PID information returned from the auth server.
type ThreePIDDeleteArg ¶
type ThreePIDDeleteArg struct { IDServer string `json:"id_server,omitempty"` Medium string `json:"medium"` Address string `json:"address"` }
ThreePIDDeleteArg represents all possible arguments of (*Client).ThreePIDDelete.
type ThreePIDUnbindArg ¶
type ThreePIDUnbindArg struct { IDServer string `json:"id_server,omitempty"` Medium string `json:"medium"` Address string `json:"address"` }
ThreePIDUnbindArg represents all possible arguments of (*Client).ThreePIDUnbind.
type TurnServersResponse ¶
type TurnServersResponse struct { Username string `json:"username"` Password string `json:"password"` URI []string `json:"uris"` TimeToLive int `json:"ttl"` }
TurnServersResponse represents the response to (*Client).TurnServers().
type User ¶ added in v0.3.0
type User struct { ID matrix.UserID `json:"user_id"` DisplayName *string `json:"display_name"` AvatarURL *matrix.URL `json:"avatar_url"` }
User is one user as returned by UserSearch.
type UserInteractiveAuthAPI ¶
type UserInteractiveAuthAPI struct { // Flows are list of stages that the server requires before allowing. Flows []struct { Stages []matrix.LoginMethod `json:"stages"` } `json:"flows"` // Params are list of parameters which contain arbitrary data required to // finish the auth flow. // Examples are the public key for Captcha. Params map[string]json.RawMessage `json:"params"` // Session represents the current session of auth that allows the server to // keep track of the auth flow. Session string `json:"session"` // Completed lists all auth successes that the server acknowledges. Completed []matrix.LoginMethod `json:"completed"` // Error and ErrorCode represents the error encountered which probably means // incorrect credentials and similar. Error string `json:"error"` ErrorCode matrix.ErrorCode `json:"errcode"` // Request is the function to call to make a request. // RequestThreePID is the function called to request a token. It passes the type of 3PID to the function. Request func(req, to interface{}) error `json:"-"` RequestThreePID func(authType string, req, to interface{}) error `json:"-"` SuccessCallback func(json.RawMessage) error `json:"-"` // contains filtered or unexported fields }
UserInteractiveAuthAPI represents the state that needs to be kept for the user interactive authentication API.
It implements https://matrix.org/docs/spec/client_server/r0.6.1#user-interactive-authentication-api.
func (*UserInteractiveAuthAPI) Auth ¶
func (u *UserInteractiveAuthAPI) Auth(req interface{}) error
Auth attempts to authenticate using the provided information in an attempt to progress in the authentication.
func (*UserInteractiveAuthAPI) AuthDummy ¶
func (u *UserInteractiveAuthAPI) AuthDummy() error
AuthDummy is a helper method to login with the dummy method. It does not need any credentials and serve only to separate different flows.
func (*UserInteractiveAuthAPI) AuthEmail ¶
func (u *UserInteractiveAuthAPI) AuthEmail(threePidCreds ThreePIDCreds) error
AuthEmail is a helper method to login with email verification.
func (*UserInteractiveAuthAPI) AuthPassword ¶
func (u *UserInteractiveAuthAPI) AuthPassword(id matrix.Identifier, password string) error
AuthPassword is a helper method to login with password.
func (*UserInteractiveAuthAPI) AuthPhone ¶
func (u *UserInteractiveAuthAPI) AuthPhone(threePidCreds ThreePIDCreds) error
AuthPhone is a helper method to login with phone verification.
func (*UserInteractiveAuthAPI) AuthRecaptcha ¶
func (u *UserInteractiveAuthAPI) AuthRecaptcha(response string) error
AuthRecaptcha is a helper method to login with recaptcha.
func (*UserInteractiveAuthAPI) AuthToken ¶
func (u *UserInteractiveAuthAPI) AuthToken(token, transactionID string) error
AuthToken is a helper method to login with token. Transaction ID should be a randomly generated ID that is persistent for each request.
func (*UserInteractiveAuthAPI) IsComplete ¶
func (u *UserInteractiveAuthAPI) IsComplete() bool
IsComplete returns true if the interactive auth is complete.
func (*UserInteractiveAuthAPI) RequestEmailToken ¶
func (u *UserInteractiveAuthAPI) RequestEmailToken(req RequestEmailTokenArg) (*RequestEmailTokenResponse, error)
RequestEmailToken requests an email token to be mailed to the specified email address for registration purposes. It returns the session ID needed in 3PID auth and the submit URL (if applicable).
func (*UserInteractiveAuthAPI) RequestPhoneToken ¶
func (u *UserInteractiveAuthAPI) RequestPhoneToken(req RequestPhoneTokenArg) (*RequestPhoneTokenResponse, error)
RequestPhoneToken requests an email token to be mailed to the specified email address for registration purposes. It returns the session ID needed in 3PID auth and the submit URL (if applicable).
func (*UserInteractiveAuthAPI) Result ¶
func (u *UserInteractiveAuthAPI) Result() (*json.RawMessage, error)
Result returns a RawMessage or an error if interactive auth is not complete yet.