Documentation ¶
Index ¶
- Constants
- Variables
- func Respond(w http.ResponseWriter, data interface{}) error
- func WriteBlankOK(w http.ResponseWriter)
- type AppService
- func (as *AppService) BotClient() *mautrix.Client
- func (as *AppService) BotIntent() *IntentAPI
- func (as *AppService) BotMXID() id.UserID
- func (as *AppService) CheckServerToken(w http.ResponseWriter, r *http.Request) (isValid bool)
- func (as *AppService) Client(userID id.UserID) *mautrix.Client
- func (as *AppService) GetLive(w http.ResponseWriter, r *http.Request)
- func (as *AppService) GetReady(w http.ResponseWriter, r *http.Request)
- func (as *AppService) GetRoom(w http.ResponseWriter, r *http.Request)
- func (as *AppService) GetUser(w http.ResponseWriter, r *http.Request)
- func (as *AppService) HasWebsocket() bool
- func (as *AppService) Intent(userID id.UserID) *IntentAPI
- func (as *AppService) NewExternalMautrixClient(userID id.UserID, token string, homeserverURL string) (*mautrix.Client, error)
- func (as *AppService) NewIntentAPI(localpart string) *IntentAPI
- func (as *AppService) NewMautrixClient(userID id.UserID) *mautrix.Client
- func (as *AppService) PostPing(w http.ResponseWriter, r *http.Request)
- func (as *AppService) PrepareWebsocket()
- func (as *AppService) PutTransaction(w http.ResponseWriter, r *http.Request)
- func (as *AppService) RequestWebsocket(ctx context.Context, cmd *WebsocketRequest, response interface{}) error
- func (as *AppService) Save(path string) error
- func (as *AppService) SendWebsocket(cmd *WebsocketRequest) error
- func (as *AppService) SetHomeserverURL(homeserverURL string) error
- func (as *AppService) SetWebsocketCommandHandler(cmd string, handler WebsocketHandler)
- func (as *AppService) Start()
- func (as *AppService) StartWebsocket(baseURL string, onConnect func()) error
- func (as *AppService) Stop()
- func (as *AppService) WebsocketHTTPProxy(cmd WebsocketCommand) (bool, interface{})
- func (as *AppService) YAML() (string, error)
- type CloseCommand
- type CreateOpts
- type DeviceListHandler
- type EnsureJoinedParams
- type Error
- type ErrorCode
- type ErrorResponse
- type EventHandler
- type EventListener
- type EventProcessor
- func (ep *EventProcessor) Dispatch(ctx context.Context, evt *event.Event)
- func (ep *EventProcessor) DispatchDeviceList(ctx context.Context, dl *mautrix.DeviceLists)
- func (ep *EventProcessor) DispatchOTK(ctx context.Context, otk *mautrix.OTKCount)
- func (ep *EventProcessor) On(evtType event.Type, handler EventHandler)
- func (ep *EventProcessor) OnDeviceList(handler DeviceListHandler)
- func (ep *EventProcessor) OnOTK(handler OTKHandler)
- func (ep *EventProcessor) PrependHandler(evtType event.Type, handler EventHandler)
- func (ep *EventProcessor) Start(ctx context.Context)
- func (ep *EventProcessor) Stop()
- type ExecMode
- type FallbackKeyMap
- type HTTPProxyRequest
- type HTTPProxyResponse
- type HostConfig
- type IntentAPI
- func (intent *IntentAPI) AddDoublePuppetValue(into interface{}) interface{}
- func (intent *IntentAPI) BanUser(ctx context.Context, roomID id.RoomID, req *mautrix.ReqBanUser, ...) (resp *mautrix.RespBanUser, err error)
- func (intent *IntentAPI) EnsureInvited(ctx context.Context, roomID id.RoomID, userID id.UserID) error
- func (intent *IntentAPI) EnsureJoined(ctx context.Context, roomID id.RoomID, extra ...EnsureJoinedParams) error
- func (intent *IntentAPI) EnsureRegistered(ctx context.Context) error
- func (intent *IntentAPI) InviteUser(ctx context.Context, roomID id.RoomID, req *mautrix.ReqInviteUser, ...) (resp *mautrix.RespInviteUser, err error)
- func (intent *IntentAPI) JoinRoomByID(ctx context.Context, roomID id.RoomID, extraContent ...map[string]interface{}) (resp *mautrix.RespJoinRoom, err error)
- func (intent *IntentAPI) KickUser(ctx context.Context, roomID id.RoomID, req *mautrix.ReqKickUser, ...) (resp *mautrix.RespKickUser, err error)
- func (intent *IntentAPI) LeaveRoom(ctx context.Context, roomID id.RoomID, extra ...interface{}) (resp *mautrix.RespLeaveRoom, err error)
- func (intent *IntentAPI) Member(ctx context.Context, roomID id.RoomID, userID id.UserID) *event.MemberEventContent
- func (intent *IntentAPI) PowerLevels(ctx context.Context, roomID id.RoomID) (pl *event.PowerLevelsEventContent, err error)
- func (intent *IntentAPI) RedactEvent(ctx context.Context, roomID id.RoomID, eventID id.EventID, ...) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) Register(ctx context.Context) error
- func (intent *IntentAPI) SendCustomMembershipEvent(ctx context.Context, roomID id.RoomID, target id.UserID, ...) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SendMassagedMessageEvent(ctx context.Context, roomID id.RoomID, eventType event.Type, ...) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SendMassagedStateEvent(ctx context.Context, roomID id.RoomID, eventType event.Type, stateKey string, ...) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SendMessageEvent(ctx context.Context, roomID id.RoomID, eventType event.Type, ...) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SendNotice(ctx context.Context, roomID id.RoomID, text string) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SendStateEvent(ctx context.Context, roomID id.RoomID, eventType event.Type, stateKey string, ...) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SendText(ctx context.Context, roomID id.RoomID, text string) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SetAvatarURL(ctx context.Context, avatarURL id.ContentURI) error
- func (intent *IntentAPI) SetDisplayName(ctx context.Context, displayName string) error
- func (intent *IntentAPI) SetPowerLevel(ctx context.Context, roomID id.RoomID, userID id.UserID, level int) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SetPowerLevels(ctx context.Context, roomID id.RoomID, levels *event.PowerLevelsEventContent) (resp *mautrix.RespSendEvent, err error)
- func (intent *IntentAPI) SetRoomAvatar(ctx context.Context, roomID id.RoomID, avatarURL id.ContentURI) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SetRoomName(ctx context.Context, roomID id.RoomID, roomName string) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) SetRoomTopic(ctx context.Context, roomID id.RoomID, topic string) (*mautrix.RespSendEvent, error)
- func (intent *IntentAPI) State(ctx context.Context, roomID id.RoomID) (mautrix.RoomStateMap, error)
- func (intent *IntentAPI) StateEvent(ctx context.Context, roomID id.RoomID, eventType event.Type, stateKey string, ...) error
- func (intent *IntentAPI) UnbanUser(ctx context.Context, roomID id.RoomID, req *mautrix.ReqUnbanUser, ...) (resp *mautrix.RespUnbanUser, err error)
- func (intent *IntentAPI) Whoami(ctx context.Context) (*mautrix.RespWhoami, error)
- type MeowWebsocketCloseCode
- type Namespace
- type NamespaceList
- type Namespaces
- type OTKCountMap
- type OTKHandler
- type QueryHandler
- type QueryHandlerStub
- type Registration
- type StateStore
- type Transaction
- type TransactionIDCache
- type WebsocketCommand
- type WebsocketHandler
- type WebsocketMessage
- type WebsocketRequest
- type WebsocketTransaction
- type WebsocketTransactionHandler
- type WebsocketTransactionResponse
Constants ¶
const ( WebsocketCloseConnReplaced = 4001 WebsocketCloseTxnNotAcknowledged = 4002 )
const DoublePuppetKey = "fi.mau.double_puppet_source"
const WebsocketCommandHTTPProxy = "http_proxy"
Variables ¶
var ( ErrWebsocketManualStop = errors.New("the websocket was disconnected manually") ErrWebsocketOverridden = errors.New("a new call to StartWebsocket overrode the previous connection") ErrWebsocketUnknownError = errors.New("an unknown error occurred") ErrWebsocketNotConnected = errors.New("websocket not connected") ErrWebsocketClosed = errors.New("websocket closed before response received") )
var EventChannelSize = 64
EventChannelSize is the size for the Events channel in Appservice instances.
var OTKChannelSize = 4
Functions ¶
func Respond ¶
func Respond(w http.ResponseWriter, data interface{}) error
Respond responds to a HTTP request with a JSON object.
func WriteBlankOK ¶
func WriteBlankOK(w http.ResponseWriter)
WriteBlankOK writes a blank OK message as a reply to a HTTP request.
Types ¶
type AppService ¶
type AppService struct { HomeserverDomain string Host HostConfig Registration *Registration Log zerolog.Logger Events chan *event.Event ToDeviceEvents chan *event.Event DeviceLists chan *mautrix.DeviceLists OTKCounts chan *mautrix.OTKCount QueryHandler QueryHandler StateStore StateStore Router *mux.Router UserAgent string HTTPClient *http.Client DefaultHTTPRetries int Live bool Ready bool StopWebsocket func(error) // ProcessID is an identifier sent to the websocket proxy for debugging connections ProcessID string WebsocketTransactionHandler WebsocketTransactionHandler DoublePuppetValue string GetProfile func(userID id.UserID, roomID id.RoomID) *event.MemberEventContent // contains filtered or unexported fields }
AppService is the main config for all appservices. It also serves as the appservice instance struct.
func CreateFull ¶
func CreateFull(opts CreateOpts) (*AppService, error)
CreateFull creates a fully configured appservice instance that can be [Start]ed and used directly.
func (*AppService) BotClient ¶
func (as *AppService) BotClient() *mautrix.Client
BotClient returns the mautrix.Client instance for the appservice's sender_localpart user.
Like with the generic Client method, AppService.BotIntent should be preferred over this.
func (*AppService) BotIntent ¶
func (as *AppService) BotIntent() *IntentAPI
BotIntent returns an IntentAPI object for the appservice's sender_localpart user.
func (*AppService) BotMXID ¶
func (as *AppService) BotMXID() id.UserID
BotMXID returns the user ID corresponding to the appservice's sender_localpart
func (*AppService) CheckServerToken ¶
func (as *AppService) CheckServerToken(w http.ResponseWriter, r *http.Request) (isValid bool)
CheckServerToken checks if the given request originated from the Matrix homeserver.
func (*AppService) Client ¶
func (as *AppService) Client(userID id.UserID) *mautrix.Client
Client returns the mautrix.Client instance for the given user ID.
Unlike AppService.Intent, this does not do any validation, and will always return a value. Usually you should prefer creating intents and using intent methods over direct client methods. You can always access the client inside an intent with [IntentAPI.Client].
func (*AppService) GetLive ¶
func (as *AppService) GetLive(w http.ResponseWriter, r *http.Request)
func (*AppService) GetReady ¶
func (as *AppService) GetReady(w http.ResponseWriter, r *http.Request)
func (*AppService) GetRoom ¶
func (as *AppService) GetRoom(w http.ResponseWriter, r *http.Request)
GetRoom handles a /rooms GET call from the homeserver.
func (*AppService) GetUser ¶
func (as *AppService) GetUser(w http.ResponseWriter, r *http.Request)
GetUser handles a /users GET call from the homeserver.
func (*AppService) HasWebsocket ¶
func (as *AppService) HasWebsocket() bool
func (*AppService) Intent ¶
func (as *AppService) Intent(userID id.UserID) *IntentAPI
Intent returns an IntentAPI object for the given user ID.
This will return nil if the given user ID has an empty localpart, or if the server name is not the same as the appservice's HomeserverDomain. It does not currently validate that the given user ID is actually in the appservice's namespace. Validation may be added later.
func (*AppService) NewExternalMautrixClient ¶
func (as *AppService) NewExternalMautrixClient(userID id.UserID, token string, homeserverURL string) (*mautrix.Client, error)
NewExternalMautrixClient creates a new mautrix.Client instance for an external user, with a token and homeserver URL separate from the main appservice.
This is primarily meant to facilitate double puppeting in bridges, and is used by [bridge.doublePuppetUtil]. Non-bridge appservices will likely not need this.
func (*AppService) NewIntentAPI ¶
func (as *AppService) NewIntentAPI(localpart string) *IntentAPI
func (*AppService) NewMautrixClient ¶
func (as *AppService) NewMautrixClient(userID id.UserID) *mautrix.Client
NewMautrixClient creates a new mautrix.Client instance for the given user ID.
This does not do any validation, and it does not cache the client. Usually you should prefer AppService.Client or AppService.Intent over this method.
func (*AppService) PostPing ¶
func (as *AppService) PostPing(w http.ResponseWriter, r *http.Request)
func (*AppService) PrepareWebsocket ¶
func (as *AppService) PrepareWebsocket()
func (*AppService) PutTransaction ¶
func (as *AppService) PutTransaction(w http.ResponseWriter, r *http.Request)
PutTransaction handles a /transactions PUT call from the homeserver.
func (*AppService) RequestWebsocket ¶
func (as *AppService) RequestWebsocket(ctx context.Context, cmd *WebsocketRequest, response interface{}) error
func (*AppService) Save ¶
func (as *AppService) Save(path string) error
Save saves this config into a file at the given path.
func (*AppService) SendWebsocket ¶
func (as *AppService) SendWebsocket(cmd *WebsocketRequest) error
func (*AppService) SetHomeserverURL ¶
func (as *AppService) SetHomeserverURL(homeserverURL string) error
SetHomeserverURL updates the appservice's homeserver URL.
Note that this does not affect already-created IntentAPI or mautrix.Client objects, so it should not be called after Intent or Client are called.
func (*AppService) SetWebsocketCommandHandler ¶
func (as *AppService) SetWebsocketCommandHandler(cmd string, handler WebsocketHandler)
func (*AppService) Start ¶
func (as *AppService) Start()
Start starts the HTTP server that listens for calls from the Matrix homeserver.
func (*AppService) StartWebsocket ¶
func (as *AppService) StartWebsocket(baseURL string, onConnect func()) error
func (*AppService) Stop ¶
func (as *AppService) Stop()
func (*AppService) WebsocketHTTPProxy ¶
func (as *AppService) WebsocketHTTPProxy(cmd WebsocketCommand) (bool, interface{})
func (*AppService) YAML ¶
func (as *AppService) YAML() (string, error)
YAML returns the config in YAML format.
type CloseCommand ¶
type CloseCommand struct { Code int `json:"-"` Command string `json:"command"` Status MeowWebsocketCloseCode `json:"status"` }
func (CloseCommand) Error ¶
func (cc CloseCommand) Error() string
type CreateOpts ¶
type CreateOpts struct { // Required, the registration file data for this appservice. Registration *Registration // Required, the homeserver's server_name. HomeserverDomain string // Required, the homeserver URL to connect to. Should be either https://address or unix:path HomeserverURL string // Required if you want to use the standard HTTP server, optional for websockets (non-standard) HostConfig HostConfig // Optional, defaults to a memory state store StateStore StateStore }
CreateOpts contains the options for initializing a new AppService instance.
type DeviceListHandler ¶
type EnsureJoinedParams ¶
type EnsureJoinedParams struct { IgnoreCache bool BotOverride *mautrix.Client }
type Error ¶
type Error struct { HTTPStatus int `json:"-"` ErrorCode ErrorCode `json:"errcode"` Message string `json:"error"` }
Error represents a Matrix protocol error.
func (Error) Write ¶
func (err Error) Write(w http.ResponseWriter)
type ErrorCode ¶
type ErrorCode string
ErrorCode is the machine-readable code in an Error.
const ( ErrUnknownToken ErrorCode = "M_UNKNOWN_TOKEN" ErrBadJSON ErrorCode = "M_BAD_JSON" ErrNotJSON ErrorCode = "M_NOT_JSON" ErrUnknown ErrorCode = "M_UNKNOWN" )
Native ErrorCodes
const (
ErrNoTransactionID ErrorCode = "NET.MAUNIUM.NO_TRANSACTION_ID"
)
Custom ErrorCodes
type ErrorResponse ¶
func (*ErrorResponse) Error ¶
func (er *ErrorResponse) Error() string
type EventListener ¶
EventListener is a function that receives events.
type EventProcessor ¶
type EventProcessor struct { ExecMode ExecMode ExecSyncWarnTime time.Duration ExecSyncTimeout time.Duration // contains filtered or unexported fields }
func NewEventProcessor ¶
func NewEventProcessor(as *AppService) *EventProcessor
func (*EventProcessor) Dispatch ¶
func (ep *EventProcessor) Dispatch(ctx context.Context, evt *event.Event)
func (*EventProcessor) DispatchDeviceList ¶
func (ep *EventProcessor) DispatchDeviceList(ctx context.Context, dl *mautrix.DeviceLists)
func (*EventProcessor) DispatchOTK ¶
func (ep *EventProcessor) DispatchOTK(ctx context.Context, otk *mautrix.OTKCount)
func (*EventProcessor) On ¶
func (ep *EventProcessor) On(evtType event.Type, handler EventHandler)
func (*EventProcessor) OnDeviceList ¶
func (ep *EventProcessor) OnDeviceList(handler DeviceListHandler)
func (*EventProcessor) OnOTK ¶
func (ep *EventProcessor) OnOTK(handler OTKHandler)
func (*EventProcessor) PrependHandler ¶
func (ep *EventProcessor) PrependHandler(evtType event.Type, handler EventHandler)
func (*EventProcessor) Start ¶
func (ep *EventProcessor) Start(ctx context.Context)
func (*EventProcessor) Stop ¶
func (ep *EventProcessor) Stop()
type FallbackKeyMap ¶
type HTTPProxyRequest ¶
type HTTPProxyResponse ¶
type HTTPProxyResponse struct { Status int `json:"status"` Headers http.Header `json:"headers"` Body json.RawMessage `json:"body"` // contains filtered or unexported fields }
func (*HTTPProxyResponse) Header ¶
func (p *HTTPProxyResponse) Header() http.Header
func (*HTTPProxyResponse) WriteHeader ¶
func (p *HTTPProxyResponse) WriteHeader(statusCode int)
type HostConfig ¶
type HostConfig struct { // Hostname can be an IP address or an absolute path for a unix socket. Hostname string `yaml:"hostname"` // Port is required when Hostname is an IP address, optional for unix sockets Port uint16 `yaml:"port"` TLSKey string `yaml:"tls_key,omitempty"` TLSCert string `yaml:"tls_cert,omitempty"` }
HostConfig contains info about how to host the appservice.
func (*HostConfig) Address ¶
func (hc *HostConfig) Address() string
Address gets the whole address of the Appservice.
func (*HostConfig) IsConfigured ¶
func (hc *HostConfig) IsConfigured() bool
func (*HostConfig) IsUnixSocket ¶
func (hc *HostConfig) IsUnixSocket() bool
type IntentAPI ¶
type IntentAPI struct { *mautrix.Client Localpart string UserID id.UserID IsCustomPuppet bool // contains filtered or unexported fields }
func (*IntentAPI) AddDoublePuppetValue ¶
func (intent *IntentAPI) AddDoublePuppetValue(into interface{}) interface{}
func (*IntentAPI) EnsureInvited ¶
func (*IntentAPI) EnsureJoined ¶
func (*IntentAPI) EnsureRegistered ¶
func (*IntentAPI) InviteUser ¶
func (*IntentAPI) JoinRoomByID ¶
func (*IntentAPI) PowerLevels ¶
func (*IntentAPI) RedactEvent ¶
func (*IntentAPI) SendCustomMembershipEvent ¶
func (*IntentAPI) SendMassagedMessageEvent ¶
func (*IntentAPI) SendMassagedStateEvent ¶
func (*IntentAPI) SendMessageEvent ¶
func (*IntentAPI) SendNotice ¶
func (*IntentAPI) SendStateEvent ¶
func (*IntentAPI) SetAvatarURL ¶
func (*IntentAPI) SetDisplayName ¶
func (*IntentAPI) SetPowerLevel ¶
func (*IntentAPI) SetPowerLevels ¶
func (*IntentAPI) SetRoomAvatar ¶
func (*IntentAPI) SetRoomName ¶
func (*IntentAPI) SetRoomTopic ¶
func (*IntentAPI) StateEvent ¶
type MeowWebsocketCloseCode ¶
type MeowWebsocketCloseCode string
const ( MeowServerShuttingDown MeowWebsocketCloseCode = "server_shutting_down" MeowConnectionReplaced MeowWebsocketCloseCode = "conn_replaced" MeowTxnNotAcknowledged MeowWebsocketCloseCode = "transactions_not_acknowledged" )
func (MeowWebsocketCloseCode) String ¶
func (mwcc MeowWebsocketCloseCode) String() string
type Namespace ¶
type Namespace struct { Regex string `yaml:"regex" json:"regex"` Exclusive bool `yaml:"exclusive" json:"exclusive"` }
Namespace is a reserved namespace in any area.
type NamespaceList ¶
type NamespaceList []Namespace
type Namespaces ¶
type Namespaces struct { UserIDs NamespaceList `yaml:"users,omitempty" json:"users,omitempty"` RoomAliases NamespaceList `yaml:"aliases,omitempty" json:"aliases,omitempty"` RoomIDs NamespaceList `yaml:"rooms,omitempty" json:"rooms,omitempty"` }
Namespaces contains the three areas that appservices can reserve parts of.
type OTKHandler ¶
type QueryHandler ¶
QueryHandler handles room alias and user ID queries from the homeserver.
type QueryHandlerStub ¶
type QueryHandlerStub struct{}
func (*QueryHandlerStub) QueryAlias ¶
func (qh *QueryHandlerStub) QueryAlias(alias string) bool
type Registration ¶
type Registration struct { ID string `yaml:"id" json:"id"` URL string `yaml:"url" json:"url"` AppToken string `yaml:"as_token" json:"as_token"` ServerToken string `yaml:"hs_token" json:"hs_token"` SenderLocalpart string `yaml:"sender_localpart" json:"sender_localpart"` RateLimited *bool `yaml:"rate_limited,omitempty" json:"rate_limited,omitempty"` Namespaces Namespaces `yaml:"namespaces" json:"namespaces"` Protocols []string `yaml:"protocols,omitempty" json:"protocols,omitempty"` SoruEphemeralEvents bool `yaml:"de.sorunome.msc2409.push_ephemeral,omitempty" json:"de.sorunome.msc2409.push_ephemeral,omitempty"` EphemeralEvents bool `yaml:"push_ephemeral,omitempty" json:"push_ephemeral,omitempty"` }
Registration contains the data in a Matrix appservice registration. See https://spec.matrix.org/v1.2/application-service-api/#registration
func CreateRegistration ¶
func CreateRegistration() *Registration
CreateRegistration creates a Registration with random appservice and homeserver tokens.
func LoadRegistration ¶
func LoadRegistration(path string) (*Registration, error)
LoadRegistration loads a YAML file and turns it into a Registration.
func (*Registration) Save ¶
func (reg *Registration) Save(path string) error
Save saves this Registration into a file at the given path.
func (*Registration) YAML ¶
func (reg *Registration) YAML() (string, error)
YAML returns the registration in YAML format.
type StateStore ¶
type StateStore interface { mautrix.StateStore IsRegistered(ctx context.Context, userID id.UserID) (bool, error) MarkRegistered(ctx context.Context, userID id.UserID) error GetPowerLevel(ctx context.Context, roomID id.RoomID, userID id.UserID) (int, error) GetPowerLevelRequirement(ctx context.Context, roomID id.RoomID, eventType event.Type) (int, error) HasPowerLevel(ctx context.Context, roomID id.RoomID, userID id.UserID, eventType event.Type) (bool, error) }
type Transaction ¶
type Transaction struct { Events []*event.Event `json:"events"` EphemeralEvents []*event.Event `json:"ephemeral,omitempty"` ToDeviceEvents []*event.Event `json:"to_device,omitempty"` DeviceLists *mautrix.DeviceLists `json:"device_lists,omitempty"` DeviceOTKCount OTKCountMap `json:"device_one_time_keys_count,omitempty"` FallbackKeys FallbackKeyMap `json:"device_unused_fallback_key_types,omitempty"` MSC2409EphemeralEvents []*event.Event `json:"de.sorunome.msc2409.ephemeral,omitempty"` MSC2409ToDeviceEvents []*event.Event `json:"de.sorunome.msc2409.to_device,omitempty"` MSC3202DeviceLists *mautrix.DeviceLists `json:"org.matrix.msc3202.device_lists,omitempty"` MSC3202DeviceOTKCount OTKCountMap `json:"org.matrix.msc3202.device_one_time_keys_count,omitempty"` MSC3202FallbackKeys FallbackKeyMap `json:"org.matrix.msc3202.device_unused_fallback_key_types,omitempty"` }
Transaction contains a list of events.
func (*Transaction) ContentString ¶
func (txn *Transaction) ContentString() string
func (*Transaction) MarshalZerologObject ¶
func (txn *Transaction) MarshalZerologObject(ctx *zerolog.Event)
type TransactionIDCache ¶
type TransactionIDCache struct {
// contains filtered or unexported fields
}
func NewTransactionIDCache ¶
func NewTransactionIDCache(size int) *TransactionIDCache
func (*TransactionIDCache) IsProcessed ¶
func (txnIDC *TransactionIDCache) IsProcessed(txnID string) bool
func (*TransactionIDCache) MarkProcessed ¶
func (txnIDC *TransactionIDCache) MarkProcessed(txnID string)
type WebsocketCommand ¶
type WebsocketCommand struct { ReqID int `json:"id,omitempty"` Command string `json:"command"` Data json.RawMessage `json:"data"` Ctx context.Context `json:"-"` }
func (*WebsocketCommand) MakeResponse ¶
func (wsc *WebsocketCommand) MakeResponse(ok bool, data interface{}) *WebsocketRequest
type WebsocketHandler ¶
type WebsocketHandler func(WebsocketCommand) (ok bool, data interface{})
type WebsocketMessage ¶
type WebsocketMessage struct { WebsocketTransaction WebsocketCommand }
type WebsocketRequest ¶
type WebsocketTransaction ¶
type WebsocketTransaction struct { Status string `json:"status"` TxnID string `json:"txn_id"` Transaction }
type WebsocketTransactionHandler ¶
type WebsocketTransactionHandler func(ctx context.Context, msg WebsocketMessage) (bool, any)
type WebsocketTransactionResponse ¶
type WebsocketTransactionResponse struct {
TxnID string `json:"txn_id"`
}