Documentation
¶
Index ¶
- Variables
- type AuthDict
- type DefaultSyncer
- func (s *DefaultSyncer) GetFilterJSON(userID string) json.RawMessage
- func (s *DefaultSyncer) OnEventType(eventType string, callback OnEventListener)
- func (s *DefaultSyncer) OnFailedSync(res *RespSync, err error) (time.Duration, error)
- func (s *DefaultSyncer) ProcessResponse(res *RespSync, since string) (err error)
- type Event
- type HTMLMessage
- type HTTPError
- type ImageInfo
- type ImageMessage
- type InMemoryStore
- func (s *InMemoryStore) LoadFilterID(userID string) string
- func (s *InMemoryStore) LoadNextBatch(userID string) string
- func (s *InMemoryStore) LoadRoom(roomID string) *Room
- func (s *InMemoryStore) LoadRoomOfAll() map[string]*Room
- func (s *InMemoryStore) SaveFilterID(userID, filterID string)
- func (s *InMemoryStore) SaveNextBatch(userID, nextBatchToken string)
- func (s *InMemoryStore) SaveRoom(room *Room)
- type MatrixClient
- func (mcli *MatrixClient) BanUser(roomID string, req *ReqBanUser) (resp *RespBanUser, err error)
- func (mcli *MatrixClient) BuildBaseURL(urlPath ...string) string
- func (mcli *MatrixClient) BuildURL(urlPath ...string) string
- func (mcli *MatrixClient) BuildURLWithQuery(urlPath []string, urlQuery map[string]string) string
- func (mcli *MatrixClient) ClearCredentials()
- func (mcli *MatrixClient) CreateFilter(filter json.RawMessage) (resp *RespCreateFilter, err error)
- func (mcli *MatrixClient) CreateRoom(req *ReqCreateRoom) (resp *RespCreateRoom, err error)
- func (mcli *MatrixClient) ForgetRoom(roomID string) (resp *RespForgetRoom, err error)
- func (mcli *MatrixClient) GetAvatarURL() (url string, err error)
- func (mcli *MatrixClient) GetDisplayName(mxid string) (resp *RespUserDisplayName, err error)
- func (mcli *MatrixClient) GetOwnDisplayName() (resp *RespUserDisplayName, err error)
- func (mcli *MatrixClient) GetPresenceList(userid string) (resp []*RespPresenceList, err error)
- func (mcli *MatrixClient) GetPresenceState(userid string) (resp *RespPresenceUser, err error)
- func (mcli *MatrixClient) GetWhois(userid string) (xagent interface{}, err error)
- func (mcli *MatrixClient) InviteUser(roomID string, req *ReqInviteUser) (resp *RespInviteUser, err error)
- func (mcli *MatrixClient) InviteUserByThirdParty(roomID string, req *ReqInvite3PID) (resp *RespInviteUser, err error)
- func (mcli *MatrixClient) JoinRoom(roomIDorAlias, serverName string, content interface{}) (resp *RespJoinRoom, err error)
- func (mcli *MatrixClient) JoinedMembers(roomID string) (resp *RespJoinedMembers, err error)
- func (mcli *MatrixClient) JoinedRooms() (resp *RespJoinedRooms, err error)
- func (mcli *MatrixClient) KickUser(roomID string, req *ReqKickUser) (resp *RespKickUser, err error)
- func (mcli *MatrixClient) LeaveRoom(roomID string) (resp *RespLeaveRoom, err error)
- func (mcli *MatrixClient) Login(req *ReqLogin) (resp *RespLogin, err error)
- func (mcli *MatrixClient) Logout() (resp *RespLogout, err error)
- func (mcli *MatrixClient) MakeRequest(method string, httpURL string, reqBody interface{}, resBody interface{}) ([]byte, error)
- func (mcli *MatrixClient) Messages(roomID, from, to string, dir rune, limit int) (resp *RespMessages, err error)
- func (mcli *MatrixClient) NodesStatus(address []string) (map[string]string, error)
- func (mcli *MatrixClient) PostPresenceList(req *ReqPresenceList) (err error)
- func (mcli *MatrixClient) RedactEvent(roomID, eventID string, req *ReqRedact) (resp *RespSendEvent, err error)
- func (mcli *MatrixClient) Register(req *ReqRegister) (*RespRegister, *RespUserInteractive, error)
- func (mcli *MatrixClient) RegisterGuest(req *ReqRegister) (*RespRegister, *RespUserInteractive, error)
- func (mcli *MatrixClient) SearchUserDirectory(req *ReqUserSearch) (resp *RespUserSearch, err error)
- func (mcli *MatrixClient) SendImage(roomID, body, url string) (*RespSendEvent, error)
- func (mcli *MatrixClient) SendMessageEvent(roomID string, eventType string, contentJSON interface{}) (resp *RespSendEvent, err error)
- func (mcli *MatrixClient) SendNotice(roomID, text string) (*RespSendEvent, error)
- func (mcli *MatrixClient) SendStateEvent(roomID, eventType, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error)
- func (mcli *MatrixClient) SendText(roomID, text string) (*RespSendEvent, error)
- func (mcli *MatrixClient) SendVideo(roomID, body, url string) (*RespSendEvent, error)
- func (mcli *MatrixClient) SetAccountData(userid, xtype string, addr2room map[common.Address]string) (err error)
- func (mcli *MatrixClient) SetAvatarURL(url string) (err error)
- func (mcli *MatrixClient) SetCredentials(userID, accessToken string)
- func (mcli *MatrixClient) SetDisplayName(displayName string) (err error)
- func (mcli *MatrixClient) SetPresenceState(req *ReqPresenceUser) (err error)
- func (mcli *MatrixClient) StateEvent(roomID, eventType string, outContent interface{}) (err error)
- func (mcli *MatrixClient) StopSync()
- func (mcli *MatrixClient) Sync() error
- func (mcli *MatrixClient) SyncRequest(timeout int, since, filterID string, fullState bool, setPresence string) (resp *RespSync, err error)
- func (mcli *MatrixClient) TurnServer() (resp *RespTurnServer, err error)
- func (mcli *MatrixClient) UnbanUser(roomID string, req *ReqUnbanUser) (resp *RespUnbanUser, err error)
- func (mcli *MatrixClient) UploadLink(link string) (*RespMediaUpload, error)
- func (mcli *MatrixClient) UploadToContentRepo(content io.Reader, contentType string, contentLength int64) (*RespMediaUpload, error)
- func (mcli *MatrixClient) UserTyping(roomID string, typing bool, timeout int64) (resp *RespTyping, err error)
- func (mcli *MatrixClient) Versions() (resp *RespVersions, err error)
- type OnEventListener
- type ReqAccountData
- type ReqBanUser
- type ReqCreateRoom
- type ReqInvite3PID
- type ReqInviteUser
- type ReqKickUser
- type ReqLogin
- type ReqPresenceList
- type ReqPresenceUser
- type ReqRedact
- type ReqRegister
- type ReqTyping
- type ReqUnbanUser
- type ReqUserSearch
- type RespAccountData
- type RespBanUser
- type RespCreateFilter
- type RespCreateRoom
- type RespError
- type RespForgetRoom
- type RespInviteUser
- type RespJoinRoom
- type RespJoinedMembers
- type RespJoinedRooms
- type RespKickUser
- type RespLeaveRoom
- type RespLogin
- type RespLogout
- type RespMediaUpload
- type RespMessages
- type RespPresenceList
- type RespPresenceUser
- type RespRegister
- type RespSendEvent
- type RespSync
- type RespTurnServer
- type RespTyping
- type RespUnbanUser
- type RespUserDisplayName
- type RespUserInteractive
- type RespUserSearch
- type RespVersions
- type Room
- type Storer
- type Syncer
- type TextMessage
- type UserInfo
- type VideoInfo
- type VideoMessage
Constants ¶
This section is empty.
Variables ¶
var MatrixHTTPClient = &http.Client{ Transport: &http.Transport{ Dial: func(netw, addr string) (net.Conn, error) { c, err := net.DialTimeout(netw, addr, time.Second*30) if err != nil { return nil, err } return c, nil }, Proxy: func(_ *http.Request) (*url.URL, error) { proxyurl := os.Getenv("http_proxy") if len(proxyurl) > 0 { return url.Parse(proxyurl) } return nil, nil }, MaxIdleConnsPerHost: 100, ResponseHeaderTimeout: time.Second * 30, }, }
MatrixHTTPClient is a custom http client
Functions ¶
This section is empty.
Types ¶
type AuthDict ¶
type AuthDict struct {
Type string `json:"type"`
Session string `json:"session"`
Mac []byte `json:"mac"`
Response string `json:"response"`
}
AuthDict is the JSON request for AuthDict
type DefaultSyncer ¶
DefaultSyncer is the default syncing implementation
func NewDefaultSyncer ¶
func NewDefaultSyncer(userID string, store Storer) *DefaultSyncer
NewDefaultSyncer returns an instantiated DefaultSyncer
func (*DefaultSyncer) GetFilterJSON ¶
func (s *DefaultSyncer) GetFilterJSON(userID string) json.RawMessage
GetFilterJSON returns a filter with a timeline limit of 50.
func (*DefaultSyncer) OnEventType ¶
func (s *DefaultSyncer) OnEventType(eventType string, callback OnEventListener)
OnEventType allows callers to be notified when there are new events for the given event type. There are no duplicate checks.
func (*DefaultSyncer) OnFailedSync ¶
OnFailedSync always returns a 5 second wait period between failed /syncs, never a fatal error.
func (*DefaultSyncer) ProcessResponse ¶
func (s *DefaultSyncer) ProcessResponse(res *RespSync, since string) (err error)
ProcessResponse 处理接收到的消息
type Event ¶
type Event struct {
StateKey *string `json:"state_key,omitempty"`
Sender string `json:"sender"`
Type string `json:"type"`
Timestamp int64 `json:"origin_server_ts"`
ID string `json:"event_id"`
RoomID string `json:"room_id"`
Content map[string]interface{} `json:"content"`
Redacts string `json:"redacts,omitempty"`
}
Event represents a single Matrix event.
func (*Event) Body ¶
Body returns the value of the "body" key in the event content if it is present and is a string.
func (*Event) MessageType ¶
MessageType returns the value of the "msgtype" key in the event content if it is present and is a string.
type HTMLMessage ¶
type HTMLMessage struct {
Body string `json:"body"`
MsgType string `json:"msgtype"`
Format string `json:"format"`
FormattedBody string `json:"formatted_body"`
}
HTMLMessage is the contents of a Matrix HTML formated message event.
func GetHTMLMessage ¶
func GetHTMLMessage(msgtype, htmlText string) HTMLMessage
GetHTMLMessage returns an HTMLMessage with the body set to a stripped version of the provided HTML, in addition to the provided HTML.
type ImageInfo ¶
type ImageInfo struct {
Height uint `json:"h,omitempty"`
Width uint `json:"w,omitempty"`
Mimetype string `json:"mimetype,omitempty"`
Size uint `json:"size,omitempty"`
}
ImageInfo contains info about an image
type ImageMessage ¶
type ImageMessage struct {
MsgType string `json:"msgtype"`
Body string `json:"body"`
URL string `json:"url"`
Info ImageInfo `json:"info"`
}
ImageMessage is an m.image event
type InMemoryStore ¶
type InMemoryStore struct {
Filters map[string]string
NextBatch map[string]string
Rooms map[string]*Room
}
InMemoryStore implements the Storer interface.
func NewInMemoryStore ¶
func NewInMemoryStore() *InMemoryStore
NewInMemoryStore constructs a new InMemoryStore.
func (*InMemoryStore) LoadFilterID ¶
func (s *InMemoryStore) LoadFilterID(userID string) string
LoadFilterID from memory.
func (*InMemoryStore) LoadNextBatch ¶
func (s *InMemoryStore) LoadNextBatch(userID string) string
LoadNextBatch from memory.
func (*InMemoryStore) LoadRoom ¶
func (s *InMemoryStore) LoadRoom(roomID string) *Room
LoadRoom from memory.
func (*InMemoryStore) LoadRoomOfAll ¶
func (s *InMemoryStore) LoadRoomOfAll() map[string]*Room
LoadRoomOfAll get all rooms from cache memeory
func (*InMemoryStore) SaveFilterID ¶
func (s *InMemoryStore) SaveFilterID(userID, filterID string)
SaveFilterID to memory.
func (*InMemoryStore) SaveNextBatch ¶
func (s *InMemoryStore) SaveNextBatch(userID, nextBatchToken string)
SaveNextBatch to memory.
type MatrixClient ¶
type MatrixClient struct {
HomeserverURL *url.URL
Prefix string
UserID string
AccessToken string
Client *http.Client
Store Storer //store rooms/tokens/ids
Syncer Syncer //process /sync responses
AppServiceUserID string
// contains filtered or unexported fields
}
MatrixClient matrix client
func NewClient ¶
func NewClient(homeserverURL, userID, accessToken, pathPrefix string, log log.Logger) (*MatrixClient, error)
NewClient creates a new Matrix Client ready for syncing
func (*MatrixClient) BanUser ¶
func (mcli *MatrixClient) BanUser(roomID string, req *ReqBanUser) (resp *RespBanUser, err error)
BanUser bans a user from a room.
func (*MatrixClient) BuildBaseURL ¶
func (mcli *MatrixClient) BuildBaseURL(urlPath ...string) string
BuildBaseURL builds a URL with the Client's homeserver/access_token set already. You must supply the prefix in the path.
func (*MatrixClient) BuildURL ¶
func (mcli *MatrixClient) BuildURL(urlPath ...string) string
BuildURL builds a URL with the Client's homserver/prefix/access_token set already.
func (*MatrixClient) BuildURLWithQuery ¶
func (mcli *MatrixClient) BuildURLWithQuery(urlPath []string, urlQuery map[string]string) string
BuildURLWithQuery builds a URL with query parameters in addition
func (*MatrixClient) ClearCredentials ¶
func (mcli *MatrixClient) ClearCredentials()
ClearCredentials removes the user ID and access token on this client instance.
func (*MatrixClient) CreateFilter ¶
func (mcli *MatrixClient) CreateFilter(filter json.RawMessage) (resp *RespCreateFilter, err error)
CreateFilter makes an HTTP request with filter
func (*MatrixClient) CreateRoom ¶
func (mcli *MatrixClient) CreateRoom(req *ReqCreateRoom) (resp *RespCreateRoom, err error)
CreateRoom create a room ,retrun the room's id
func (*MatrixClient) ForgetRoom ¶
func (mcli *MatrixClient) ForgetRoom(roomID string) (resp *RespForgetRoom, err error)
ForgetRoom forgets a room entirely.
func (*MatrixClient) GetAvatarURL ¶
func (mcli *MatrixClient) GetAvatarURL() (url string, err error)
GetAvatarURL get some one's avatar_url
func (*MatrixClient) GetDisplayName ¶
func (mcli *MatrixClient) GetDisplayName(mxid string) (resp *RespUserDisplayName, err error)
GetDisplayName get a user's dislayname according to profile
func (*MatrixClient) GetOwnDisplayName ¶
func (mcli *MatrixClient) GetOwnDisplayName() (resp *RespUserDisplayName, err error)
GetOwnDisplayName get own's displayname
func (*MatrixClient) GetPresenceList ¶
func (mcli *MatrixClient) GetPresenceList(userid string) (resp []*RespPresenceList, err error)
GetPresenceList Presence/list/{userId}
func (*MatrixClient) GetPresenceState ¶
func (mcli *MatrixClient) GetPresenceState(userid string) (resp *RespPresenceUser, err error)
GetPresenceState Presence/{userId}/status
func (*MatrixClient) GetWhois ¶
func (mcli *MatrixClient) GetWhois(userid string) (xagent interface{}, err error)
GetWhois get user's track info
func (*MatrixClient) InviteUser ¶
func (mcli *MatrixClient) InviteUser(roomID string, req *ReqInviteUser) (resp *RespInviteUser, err error)
InviteUser invites a user to a room.
func (*MatrixClient) InviteUserByThirdParty ¶
func (mcli *MatrixClient) InviteUserByThirdParty(roomID string, req *ReqInvite3PID) (resp *RespInviteUser, err error)
InviteUserByThirdParty invites a third-party identifier to a room.
func (*MatrixClient) JoinRoom ¶
func (mcli *MatrixClient) JoinRoom(roomIDorAlias, serverName string, content interface{}) (resp *RespJoinRoom, err error)
JoinRoom join a room ,the content is user's info
func (*MatrixClient) JoinedMembers ¶
func (mcli *MatrixClient) JoinedMembers(roomID string) (resp *RespJoinedMembers, err error)
JoinedMembers returns a map of joined room members. In general, usage of this API is discouraged in favour of /sync, as calling this API can race with incoming membership changes.
func (*MatrixClient) JoinedRooms ¶
func (mcli *MatrixClient) JoinedRooms() (resp *RespJoinedRooms, err error)
JoinedRooms returns a list of rooms which the client is joined to. In general, usage of this API is discouraged in favour of /sync, as calling this API can race with incoming membership changes.
func (*MatrixClient) KickUser ¶
func (mcli *MatrixClient) KickUser(roomID string, req *ReqKickUser) (resp *RespKickUser, err error)
KickUser kicks a user from a room.
func (*MatrixClient) LeaveRoom ¶
func (mcli *MatrixClient) LeaveRoom(roomID string) (resp *RespLeaveRoom, err error)
LeaveRoom leave room
func (*MatrixClient) Login ¶
func (mcli *MatrixClient) Login(req *ReqLogin) (resp *RespLogin, err error)
Login sign in a homeserver
func (*MatrixClient) Logout ¶
func (mcli *MatrixClient) Logout() (resp *RespLogout, err error)
Logout sign out
func (*MatrixClient) MakeRequest ¶
func (mcli *MatrixClient) MakeRequest(method string, httpURL string, reqBody interface{}, resBody interface{}) ([]byte, error)
MakeRequest makes a JSON HTTP request to the given URL
func (*MatrixClient) Messages ¶
func (mcli *MatrixClient) Messages(roomID, from, to string, dir rune, limit int) (resp *RespMessages, err error)
Messages list of message and state events for a room It uses pagination query parameters to paginate history in the room.
func (*MatrixClient) NodesStatus ¶
func (mcli *MatrixClient) NodesStatus(address []string) (map[string]string, error)
NodesStatus direct get nodes status
func (*MatrixClient) PostPresenceList ¶
func (mcli *MatrixClient) PostPresenceList(req *ReqPresenceList) (err error)
PostPresenceList Presence/list/{userId} invite!=remove)
func (*MatrixClient) RedactEvent ¶
func (mcli *MatrixClient) RedactEvent(roomID, eventID string, req *ReqRedact) (resp *RespSendEvent, err error)
RedactEvent redacts the given event.
func (*MatrixClient) Register ¶
func (mcli *MatrixClient) Register(req *ReqRegister) (*RespRegister, *RespUserInteractive, error)
Register Registe a user on a homeserver
func (*MatrixClient) RegisterGuest ¶
func (mcli *MatrixClient) RegisterGuest(req *ReqRegister) (*RespRegister, *RespUserInteractive, error)
RegisterGuest register as a guest
func (*MatrixClient) SearchUserDirectory ¶
func (mcli *MatrixClient) SearchUserDirectory(req *ReqUserSearch) (resp *RespUserSearch, err error)
SearchUserDirectory Performs a search for users on the homeserver
func (*MatrixClient) SendImage ¶
func (mcli *MatrixClient) SendImage(roomID, body, url string) (*RespSendEvent, error)
SendImage sends an m.room.message event into the given room with a msgtype of m.image
func (*MatrixClient) SendMessageEvent ¶
func (mcli *MatrixClient) SendMessageEvent(roomID string, eventType string, contentJSON interface{}) (resp *RespSendEvent, err error)
SendMessageEvent sends a message event into a room
func (*MatrixClient) SendNotice ¶
func (mcli *MatrixClient) SendNotice(roomID, text string) (*RespSendEvent, error)
SendNotice sends an m.room.message event into the given room with a msgtype of m.notice
func (*MatrixClient) SendStateEvent ¶
func (mcli *MatrixClient) SendStateEvent(roomID, eventType, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error)
SendStateEvent sends a state event into a room
func (*MatrixClient) SendText ¶
func (mcli *MatrixClient) SendText(roomID, text string) (*RespSendEvent, error)
SendText sends an m.room.message event into the given room with a msgtype of m.text
func (*MatrixClient) SendVideo ¶
func (mcli *MatrixClient) SendVideo(roomID, body, url string) (*RespSendEvent, error)
SendVideo sends an m.room.message event into the given room with a msgtype of m.video
func (*MatrixClient) SetAccountData ¶
func (mcli *MatrixClient) SetAccountData(userid, xtype string, addr2room map[common.Address]string) (err error)
SetAccountData user/{userId}/account_data/{type}
func (*MatrixClient) SetAvatarURL ¶
func (mcli *MatrixClient) SetAvatarURL(url string) (err error)
SetAvatarURL set user's avatar_url
func (*MatrixClient) SetCredentials ¶
func (mcli *MatrixClient) SetCredentials(userID, accessToken string)
SetCredentials sets the user ID and access token on this client instance.
func (*MatrixClient) SetDisplayName ¶
func (mcli *MatrixClient) SetDisplayName(displayName string) (err error)
SetDisplayName user's displayname
func (*MatrixClient) SetPresenceState ¶
func (mcli *MatrixClient) SetPresenceState(req *ReqPresenceUser) (err error)
SetPresenceState Presence/{userId}/status
func (*MatrixClient) StateEvent ¶
func (mcli *MatrixClient) StateEvent(roomID, eventType string, outContent interface{}) (err error)
StateEvent gets a single state event in a room. It will attempt to JSON unmarshal into the given "outContent" struct with the HTTP response body, or return an error.
func (*MatrixClient) Sync ¶
func (mcli *MatrixClient) Sync() error
Sync starts syncing with the provided Homeserver.
func (*MatrixClient) SyncRequest ¶
func (mcli *MatrixClient) SyncRequest(timeout int, since, filterID string, fullState bool, setPresence string) (resp *RespSync, err error)
SyncRequest makes an sync HTTP request
func (*MatrixClient) TurnServer ¶
func (mcli *MatrixClient) TurnServer() (resp *RespTurnServer, err error)
TurnServer returns turn server details and credentials for the client to use when initiating calls.
func (*MatrixClient) UnbanUser ¶
func (mcli *MatrixClient) UnbanUser(roomID string, req *ReqUnbanUser) (resp *RespUnbanUser, err error)
UnbanUser unbans a user from a room.
func (*MatrixClient) UploadLink ¶
func (mcli *MatrixClient) UploadLink(link string) (*RespMediaUpload, error)
UploadLink uploads an HTTP URL and then returns an MXC URI.
func (*MatrixClient) UploadToContentRepo ¶
func (mcli *MatrixClient) UploadToContentRepo(content io.Reader, contentType string, contentLength int64) (*RespMediaUpload, error)
UploadToContentRepo uploads the given bytes to the content repository and returns an MXC URI.
func (*MatrixClient) UserTyping ¶
func (mcli *MatrixClient) UserTyping(roomID string, typing bool, timeout int64) (resp *RespTyping, err error)
UserTyping sets the typing status of the user.
func (*MatrixClient) Versions ¶
func (mcli *MatrixClient) Versions() (resp *RespVersions, err error)
Versions retruns the matrix client-server-api's version
type OnEventListener ¶
type OnEventListener func(x *Event)
OnEventListener can be used with DefaultSyncer.OnEventType to be informed of incoming events.
type ReqAccountData ¶
type ReqAccountData struct {
//Addresshex string
//Roomid []string
AccountData map[string]interface{} `json:"account_data"`
}
ReqAccountData is the JSON request for AccountData
type ReqBanUser ¶
ReqBanUser is the JSON request for BanUser
type ReqCreateRoom ¶
type ReqCreateRoom struct {
Visibility string `json:"visibility,omitempty"`
RoomAliasName string `json:"room_alias_name,omitempty"`
Name string `json:"name,omitempty"`
Topic string `json:"topic,omitempty"`
Invite []string `json:"invite,omitempty"`
Invite3PID []ReqInvite3PID `json:"invite_3pid,omitempty"`
CreationContent map[string]interface{} `json:"creation_content,omitempty"`
InitialState []Event `json:"initial_state,omitempty"`
Preset string `json:"preset,omitempty"`
IsDirect bool `json:"is_direct,omitempty"`
}
ReqCreateRoom is the JSON request for CreateRoom
type ReqInvite3PID ¶
type ReqInvite3PID struct {
IDServer string `json:"id_server"`
Medium string `json:"medium"`
Address string `json:"address"`
}
ReqInvite3PID is the JSON request for Invite3PID
type ReqInviteUser ¶
type ReqInviteUser struct {
UserID string `json:"user_id"`
}
ReqInviteUser is the JSON request for InviteUser
type ReqKickUser ¶
ReqKickUser is the JSON request for KickUser
type ReqLogin ¶
type ReqLogin struct {
Type string `json:"type"`
Password string `json:"password,omitempty"`
Medium string `json:"medium,omitempty"`
User string `json:"user,omitempty"`
Address string `json:"address,omitempty"`
Token string `json:"token,omitempty"`
DeviceID string `json:"device_id,omitempty"`
InitialDeviceDisplayName string `json:"initial_device_display_name,omitempty"`
}
ReqLogin is the JSON request for Login
type ReqPresenceList ¶
ReqPresenceList is the JSON request for PresenceList
type ReqPresenceUser ¶
type ReqPresenceUser struct {
Presence string `json:"presence"`
StatusMsg string `json:"status_msg"`
}
ReqPresenceUser is the JSON request for PresenceUser
type ReqRedact ¶
type ReqRedact struct {
Reason string `json:"reason,omitempty"`
}
ReqRedact is the JSON request for Redact
type ReqRegister ¶
type ReqRegister struct {
Username string `json:"username,omitempty"`
BindEmail bool `json:"bind_email,omitempty"`
Password string `json:"password,omitempty"`
DeviceID string `json:"device_id,omitempty"`
InitialDeviceDisplayName string `json:"initial_device_display_name"`
Auth AuthDict `json:"auth,omitempty"`
Type string `json:"type,omitempty"`
Admin bool `json:"admin"`
}
ReqRegister is the JSON request for Register
type ReqUnbanUser ¶
type ReqUnbanUser struct {
UserID string `json:"user_id"`
}
ReqUnbanUser is the JSON request for UnbanUser
type ReqUserSearch ¶
type ReqUserSearch struct {
Limit int `json:"limit,omitempty"`
SearchTerm string `json:"search_term"`
}
ReqUserSearch is the JSON request for UserSearch
type RespAccountData ¶
type RespAccountData struct {
Events []Event `json:"events"`
}
RespAccountData is the JSON for AccountData
type RespCreateFilter ¶
type RespCreateFilter struct {
FilterID string `json:"filter_id"`
}
RespCreateFilter is the JSON response for CreateFilter
type RespCreateRoom ¶
type RespCreateRoom struct {
RoomID string `json:"room_id"`
}
RespCreateRoom is the JSON response for CreateRoom
type RespError ¶
RespError is the standard JSON error response from Homeservers. It also implements the Golang "error" interface.
type RespForgetRoom ¶
type RespForgetRoom struct{}
RespForgetRoom is the JSON response for ForgetRoom
type RespInviteUser ¶
type RespInviteUser struct{}
RespInviteUser is the JSON response for InviteUser
type RespJoinRoom ¶
type RespJoinRoom struct {
RoomID string `json:"room_id"`
}
RespJoinRoom is the JSON response for JoinRoom
type RespJoinedMembers ¶
type RespJoinedMembers struct {
Joined map[string]struct {
DisplayName *string `json:"display_name"`
AvatarURL *string `json:"avatar_url"`
} `json:"joined"`
}
RespJoinedMembers is the JSON response for JoinedMembers
type RespJoinedRooms ¶
type RespJoinedRooms struct {
JoinedRooms []string `json:"joined_rooms"`
}
RespJoinedRooms is the JSON response for JoinedRooms
type RespLogin ¶
type RespLogin struct {
AccessToken string `json:"access_token"`
DeviceID string `json:"device_id"`
HomeServer string `json:"home_server"`
UserID string `json:"user_id"`
}
RespLogin is the JSON response for Login
type RespMediaUpload ¶
type RespMediaUpload struct {
ContentURI string `json:"content_uri"`
}
RespMediaUpload is the JSON response for MediaUpload
type RespMessages ¶
type RespMessages struct {
Start string `json:"start"`
Chunk []Event `json:"chunk"`
End string `json:"end"`
}
RespMessages is the JSON response for Messages
type RespPresenceList ¶
type RespPresenceList struct {
Accepted interface{} `json:"accepted"`
LastActiveAgo int `json:"last_active_ago"`
StatusMsg string `json:"status_msg"`
CurrentlyActive bool `json:"currently_active"`
UserID string `json:"user_id"`
Presence string `json:"presence"`
}
RespPresenceList is the JSON response for PresenceList
type RespPresenceUser ¶
type RespPresenceUser struct {
LastActiveAgo int `json:"last_active_ago"`
StatusMsg string `json:"status_msg"`
CurrentlyActive bool `json:"currently_active"`
UserID string `json:"user_id"`
Presence string `json:"presence"`
}
RespPresenceUser is the JSON response for PresenceUser
type RespRegister ¶
type RespRegister struct {
AccessToken string `json:"access_token"`
DeviceID string `json:"device_id"`
HomeServer string `json:"home_server"`
RefreshToken string `json:"refresh_token"`
UserID string `json:"user_id"`
}
RespRegister is the JSON response for Register
type RespSendEvent ¶
type RespSendEvent struct {
EventID string `json:"event_id"`
}
RespSendEvent is the JSON response for SendEvent
type RespSync ¶
type RespSync struct {
NextBatch string `json:"next_batch"`
AccountData struct {
Events []Event `json:"events"`
} `json:"account_data"`
Presence struct {
Events []Event `json:"events"`
} `json:"presence"`
Rooms struct {
Leave map[string]struct {
State struct {
Events []Event `json:"events"`
} `json:"state"`
Timeline struct {
Events []Event `json:"events"`
Limited bool `json:"limited"`
PrevBatch string `json:"prev_batch"`
} `json:"timeline"`
} `json:"leave"`
Join map[string]struct {
State struct {
Events []Event `json:"events"`
} `json:"state"`
Timeline struct {
Events []Event `json:"events"`
Limited bool `json:"limited"`
PrevBatch string `json:"prev_batch"`
} `json:"timeline"`
} `json:"join"`
Invite map[string]struct {
State struct {
Events []Event
} `json:"invite_state"`
} `json:"invite"`
} `json:"rooms"`
}
RespSync is the JSON response of sync
type RespTurnServer ¶
type RespTurnServer struct {
Username string `json:"username"`
Password string `json:"password"`
TTL int `json:"ttl"`
URIs []string `json:"uris"`
}
RespTurnServer is the JSON response of turn server
type RespUserDisplayName ¶
type RespUserDisplayName struct {
DisplayName string `json:"displayname"`
}
RespUserDisplayName is the JSON response for UserDisplayName
type RespUserInteractive ¶
type RespUserInteractive struct {
Flows []struct {
Stages []string `json:"stages"`
} `json:"flows"`
Params map[string]interface{} `json:"params"`
Session string `json:"string"`
Completed []string `json:"completed"`
ErrCode string `json:"errcode"`
Error string `json:"error"`
}
RespUserInteractive is the JSON response for UserInteractive
func (RespUserInteractive) HasSingleStageFlow ¶
func (r RespUserInteractive) HasSingleStageFlow(stageName string) bool
HasSingleStageFlow returns true if there exists at least 1 Flow with a single stage of stageName.
type RespUserSearch ¶
RespUserSearch is the JSON for UserSearch
type RespVersions ¶
type RespVersions struct {
Versions []string `json:"versions"`
}
RespVersions is the JSON response for get c-s-api version
type Room ¶
type Room struct {
ID string
Alias string
State map[string]map[string]*Event //eventType->StateKey->Event
}
Room represents a single Matrix room.
func (Room) GetMembershipState ¶
GetMembershipState returns the membership state of the given user ID in this room. If there is no entry for this member, 'leave' is returned for consistency with left users.
func (Room) GetStateEvent ¶
GetStateEvent returns the state event for the given type/state_key combo, or nil.
func (Room) UpdateState ¶
UpdateState updates the room's current state with the given Event. This will clobber events based on the type/state_key combination.
type Storer ¶
type Storer interface {
SaveFilterID(userID, filterID string)
LoadFilterID(userID string) string
SaveNextBatch(userID, nextBatchToken string)
LoadNextBatch(userID string) string
SaveRoom(room *Room)
LoadRoom(roomID string) *Room
LoadRoomOfAll() map[string]*Room
}
Storer is an interface which must be satisfied to store client data.
type Syncer ¶
type Syncer interface {
ProcessResponse(resp *RespSync, since string) error
OnFailedSync(res *RespSync, err error) (time.Duration, error)
GetFilterJSON(userID string) json.RawMessage
}
Syncer represents an interface that must be satisfied in order to do /sync requests on a client.
type TextMessage ¶
TextMessage is the contents of a Matrix formated message event.
type UserInfo ¶
type UserInfo struct {
DisplayName string `json:"display_name"`
AvatarURL string `json:"avatar_url"`
UserID string `json:"user_id"`
}
UserInfo is a polular JSON for UserSearch
type VideoInfo ¶
type VideoInfo struct {
Mimetype string `json:"mimetype,omitempty"`
ThumbnailInfo ImageInfo `json:"thumbnail_info"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
Height uint `json:"h,omitempty"`
Width uint `json:"w,omitempty"`
Duration uint `json:"duration,omitempty"`
Size uint `json:"size,omitempty"`
}
VideoInfo contains info about a video