Documentation ¶
Overview ¶
Package matrix contains wrappers for mautrix for use by the UI of gomuks.
Index ¶
- Variables
- type Container
- func (c *Container) Client() *mautrix.Client
- func (c *Container) CreateRoom(req *mautrix.ReqCreateRoom) (*rooms.Room, error)
- func (c *Container) Crypto() ifc.Crypto
- func (c *Container) Download(uri id.ContentURI, file *attachment.EncryptedFile) (data []byte, err error)
- func (c *Container) DownloadToDisk(uri id.ContentURI, file *attachment.EncryptedFile, target string) (fullPath string, err error)
- func (c *Container) FetchMembers(room *rooms.Room) error
- func (c *Container) GetCachePath(uri id.ContentURI) string
- func (c *Container) GetDownloadURL(uri id.ContentURI) string
- func (c *Container) GetEvent(room *rooms.Room, eventID id.EventID) (*muksevt.Event, error)
- func (c *Container) GetHistory(room *rooms.Room, limit int, dbPointer uint64) ([]*muksevt.Event, uint64, error)
- func (c *Container) GetOrCreateRoom(roomID id.RoomID) *rooms.Room
- func (c *Container) GetRoom(roomID id.RoomID) *rooms.Room
- func (c *Container) HandleDirectChatInfo(_ mautrix.EventSource, evt *event.Event)
- func (c *Container) HandleEdit(room *rooms.Room, editsID id.EventID, editEvent *muksevt.Event)
- func (c *Container) HandleEncrypted(source mautrix.EventSource, mxEvent *event.Event)
- func (c *Container) HandleEncryptedUnsupported(source mautrix.EventSource, mxEvent *event.Event)
- func (c *Container) HandleMembership(source mautrix.EventSource, evt *event.Event)
- func (c *Container) HandleMessage(source mautrix.EventSource, mxEvent *event.Event)
- func (c *Container) HandlePreferences(source mautrix.EventSource, evt *event.Event)
- func (c *Container) HandlePushRules(_ mautrix.EventSource, evt *event.Event)
- func (c *Container) HandleReaction(room *rooms.Room, reactsTo id.EventID, reactEvent *muksevt.Event)
- func (c *Container) HandleReadReceipt(source mautrix.EventSource, evt *event.Event)
- func (c *Container) HandleRedaction(source mautrix.EventSource, evt *event.Event)
- func (c *Container) HandleTag(_ mautrix.EventSource, evt *event.Event)
- func (c *Container) HandleTyping(_ mautrix.EventSource, evt *event.Event)
- func (c *Container) InitClient() error
- func (c *Container) Initialized() bool
- func (c *Container) JoinRoom(roomID id.RoomID, server string) (*rooms.Room, error)
- func (c *Container) LeaveRoom(roomID id.RoomID) error
- func (c *Container) Login(user, password string) error
- func (c *Container) Logout()
- func (c *Container) MarkRead(roomID id.RoomID, eventID id.EventID)
- func (c *Container) OnLogin()
- func (c *Container) PasswordLogin(user, password string) error
- func (c *Container) Preferences() *config.UserPreferences
- func (c *Container) PrepareMarkdownMessage(roomID id.RoomID, msgtype event.MessageType, text, html string, ...) *muksevt.Event
- func (c *Container) PrepareMediaMessage(room *rooms.Room, path string, rel *ifc.Relation) (*muksevt.Event, error)
- func (c *Container) PushRules() *pushrules.PushRuleset
- func (c *Container) Redact(roomID id.RoomID, eventID id.EventID, reason string) error
- func (c *Container) SendEvent(evt *muksevt.Event) (id.EventID, error)
- func (c *Container) SendPreferencesToMatrix()
- func (c *Container) SendTyping(roomID id.RoomID, typing bool)
- func (c *Container) SingleSignOn() error
- func (c *Container) Start()
- func (c *Container) Stop()
- func (c *Container) UIAFallback(loginType mautrix.AuthType, sessionID string) error
- func (c *Container) UpdatePushRules()
- func (c *Container) UploadMedia(path string, encrypt bool) (*ifc.UploadedMediaInfo, error)
- type GomuksSyncer
- func (s *GomuksSyncer) GetFilterJSON(_ id.UserID) *mautrix.Filter
- func (s *GomuksSyncer) OnEventType(eventType event.Type, callback mautrix.EventHandler)
- func (s *GomuksSyncer) OnFailedSync(res *mautrix.RespSync, err error) (time.Duration, error)
- func (s *GomuksSyncer) OnSync(callback mautrix.SyncHandler)
- func (s *GomuksSyncer) ProcessResponse(res *mautrix.RespSync, since string) (err error)
- type HistoryManager
- func (hm *HistoryManager) Append(room *rooms.Room, events []*event.Event) ([]*muksevt.Event, error)
- func (hm *HistoryManager) Close() error
- func (hm *HistoryManager) Get(room *rooms.Room, eventID id.EventID) (evt *muksevt.Event, err error)
- func (hm *HistoryManager) Load(room *rooms.Room, num int, ptrStart uint64) (events []*muksevt.Event, newPtrStart uint64, err error)
- func (hm *HistoryManager) Prepend(room *rooms.Room, events []*event.Event) ([]*muksevt.Event, uint64, error)
- func (hm *HistoryManager) Update(room *rooms.Room, eventID id.EventID, update func(evt *muksevt.Event) error) error
- type StubSyncingModal
Constants ¶
This section is empty.
Variables ¶
var ( EventNotFoundError = errors.New("event not found") RoomNotFoundError = errors.New("room not found") )
var AccountDataGomuksPreferences = event.Type{ Type: "net.maunium.gomuks.preferences", Class: event.AccountDataEventType, }
var ErrCantEditOthersMessage = errors.New("can't edit message sent by someone else")
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is a wrapper for a mautrix Client and some other stuff.
It is used for all Matrix calls from the UI and Matrix event handlers.
func NewContainer ¶
NewContainer creates a new Container for the given Gomuks instance.
func (*Container) CreateRoom ¶
CreateRoom attempts to create a new room and join the user.
func (*Container) Download ¶
func (c *Container) Download(uri id.ContentURI, file *attachment.EncryptedFile) (data []byte, err error)
Download fetches the given Matrix content (mxc) URL and returns the data, homeserver, file ID and potential errors.
The file will be either read from the media cache (if found) or downloaded from the server.
func (*Container) DownloadToDisk ¶
func (c *Container) DownloadToDisk(uri id.ContentURI, file *attachment.EncryptedFile, target string) (fullPath string, err error)
func (*Container) GetCachePath ¶
func (c *Container) GetCachePath(uri id.ContentURI) string
GetCachePath gets the path to the cached version of the given homeserver:fileID combination. The file may or may not exist, use Download() to ensure it has been cached.
func (*Container) GetDownloadURL ¶
func (c *Container) GetDownloadURL(uri id.ContentURI) string
func (*Container) GetHistory ¶
func (c *Container) GetHistory(room *rooms.Room, limit int, dbPointer uint64) ([]*muksevt.Event, uint64, error)
GetHistory fetches room history.
func (*Container) GetOrCreateRoom ¶
GetOrCreateRoom gets the room instance stored in the session.
func (*Container) HandleDirectChatInfo ¶
func (c *Container) HandleDirectChatInfo(_ mautrix.EventSource, evt *event.Event)
func (*Container) HandleEdit ¶
func (*Container) HandleEncrypted ¶
func (c *Container) HandleEncrypted(source mautrix.EventSource, mxEvent *event.Event)
func (*Container) HandleEncryptedUnsupported ¶ added in v0.1.1
func (c *Container) HandleEncryptedUnsupported(source mautrix.EventSource, mxEvent *event.Event)
func (*Container) HandleMembership ¶
func (c *Container) HandleMembership(source mautrix.EventSource, evt *event.Event)
HandleMembership is the event handler for the m.room.member state event.
func (*Container) HandleMessage ¶
func (c *Container) HandleMessage(source mautrix.EventSource, mxEvent *event.Event)
HandleMessage is the event handler for the m.room.message timeline event.
func (*Container) HandlePreferences ¶
func (c *Container) HandlePreferences(source mautrix.EventSource, evt *event.Event)
func (*Container) HandlePushRules ¶
func (c *Container) HandlePushRules(_ mautrix.EventSource, evt *event.Event)
HandlePushRules is the event handler for the m.push_rules account data event.
func (*Container) HandleReaction ¶
func (*Container) HandleReadReceipt ¶
func (c *Container) HandleReadReceipt(source mautrix.EventSource, evt *event.Event)
func (*Container) HandleRedaction ¶
func (c *Container) HandleRedaction(source mautrix.EventSource, evt *event.Event)
func (*Container) HandleTag ¶
func (c *Container) HandleTag(_ mautrix.EventSource, evt *event.Event)
HandleTag is the event handler for the m.tag account data event.
func (*Container) HandleTyping ¶
func (c *Container) HandleTyping(_ mautrix.EventSource, evt *event.Event)
HandleTyping is the event handler for the m.typing event.
func (*Container) InitClient ¶
InitClient initializes the mautrix client and connects to the homeserver specified in the config.
func (*Container) Initialized ¶
Initialized returns whether or not the mautrix client is initialized (see InitClient())
func (*Container) Login ¶
Login sends a password login request with the given username and password.
func (*Container) Logout ¶
func (c *Container) Logout()
Logout revokes the access token, stops the syncer and calls the OnLogout() method of the UI.
func (*Container) OnLogin ¶
func (c *Container) OnLogin()
OnLogin initializes the syncer and updates the room list.
func (*Container) PasswordLogin ¶
func (*Container) Preferences ¶
func (c *Container) Preferences() *config.UserPreferences
func (*Container) PrepareMarkdownMessage ¶
func (*Container) PrepareMediaMessage ¶ added in v0.2.0
func (*Container) PushRules ¶
func (c *Container) PushRules() *pushrules.PushRuleset
PushRules returns the push notification rules. If no push rules are cached, UpdatePushRules() will be called first.
func (*Container) SendPreferencesToMatrix ¶
func (c *Container) SendPreferencesToMatrix()
func (*Container) SendTyping ¶
SendTyping sets whether or not the user is typing in the given room.
func (*Container) SingleSignOn ¶
func (*Container) Start ¶
func (c *Container) Start()
Start moves the UI to the main view, calls OnLogin() and runs the syncer forever until stopped with Stop()
func (*Container) UIAFallback ¶ added in v0.2.2
func (*Container) UpdatePushRules ¶
func (c *Container) UpdatePushRules()
UpdatePushRules fetches the push notification rules from the server and stores them in the current Session object.
func (*Container) UploadMedia ¶ added in v0.2.0
type GomuksSyncer ¶
type GomuksSyncer struct { FirstSyncDone bool InitDoneCallback func() FirstDoneCallback func() Progress ifc.SyncingModal // contains filtered or unexported fields }
func NewGomuksSyncer ¶
func NewGomuksSyncer(rooms *rooms.RoomCache) *GomuksSyncer
NewGomuksSyncer returns an instantiated GomuksSyncer
func (*GomuksSyncer) GetFilterJSON ¶
func (s *GomuksSyncer) GetFilterJSON(_ id.UserID) *mautrix.Filter
GetFilterJSON returns a filter with a timeline limit of 50.
func (*GomuksSyncer) OnEventType ¶
func (s *GomuksSyncer) OnEventType(eventType event.Type, callback mautrix.EventHandler)
OnEventType allows callers to be notified when there are new events for the given event type. There are no duplicate checks.
func (*GomuksSyncer) OnFailedSync ¶
OnFailedSync always returns a 10 second wait period between failed /syncs, never a fatal error.
func (*GomuksSyncer) OnSync ¶
func (s *GomuksSyncer) OnSync(callback mautrix.SyncHandler)
func (*GomuksSyncer) ProcessResponse ¶
func (s *GomuksSyncer) ProcessResponse(res *mautrix.RespSync, since string) (err error)
ProcessResponse processes a Matrix sync response.
type HistoryManager ¶
func NewHistoryManager ¶
func NewHistoryManager(dbPath string) (*HistoryManager, error)
func (*HistoryManager) Close ¶
func (hm *HistoryManager) Close() error
type StubSyncingModal ¶
type StubSyncingModal struct{}
func (StubSyncingModal) Close ¶
func (s StubSyncingModal) Close()
func (StubSyncingModal) SetIndeterminate ¶
func (s StubSyncingModal) SetIndeterminate()
func (StubSyncingModal) SetMessage ¶
func (s StubSyncingModal) SetMessage(s2 string)
func (StubSyncingModal) SetSteps ¶
func (s StubSyncingModal) SetSteps(i int)
func (StubSyncingModal) Step ¶
func (s StubSyncingModal) Step()