Documentation ¶
Index ¶
- Constants
- Variables
- func CleanPhoneNumber(phone string) (string, error)
- type APNsPushConfig
- type Avatar
- type BackfillMessage
- type BackfillReaction
- type BackfillingNetworkAPI
- type Bridge
- func (br *Bridge) FindCachedPortalReceiver(id networkid.PortalID, maybeReceiver networkid.UserLoginID) networkid.PortalKey
- func (br *Bridge) FindPortalReceiver(ctx context.Context, id networkid.PortalID, ...) (networkid.PortalKey, error)
- func (br *Bridge) GetAllPortalsWithMXID(ctx context.Context) ([]*Portal, error)
- func (br *Bridge) GetCachedUserLoginByID(id networkid.UserLoginID) *UserLogin
- func (br *Bridge) GetCurrentBridgeStates() (states []status.BridgeState)
- func (br *Bridge) GetExistingPortalByKey(ctx context.Context, key networkid.PortalKey) (*Portal, error)
- func (br *Bridge) GetExistingUserByMXID(ctx context.Context, userID id.UserID) (*User, error)
- func (br *Bridge) GetExistingUserLoginByID(ctx context.Context, id networkid.UserLoginID) (*UserLogin, error)
- func (br *Bridge) GetGhostByID(ctx context.Context, id networkid.UserID) (*Ghost, error)
- func (br *Bridge) GetGhostByMXID(ctx context.Context, mxid id.UserID) (*Ghost, error)
- func (br *Bridge) GetPortalByKey(ctx context.Context, key networkid.PortalKey) (*Portal, error)
- func (br *Bridge) GetPortalByMXID(ctx context.Context, mxid id.RoomID) (*Portal, error)
- func (br *Bridge) GetUserByMXID(ctx context.Context, userID id.UserID) (*User, error)
- func (br *Bridge) GetUserLoginsInPortal(ctx context.Context, portal networkid.PortalKey) ([]*UserLogin, error)
- func (br *Bridge) NewBridgeStateQueue(user status.BridgeStateFiller) *BridgeStateQueue
- func (br *Bridge) QueueMatrixEvent(ctx context.Context, evt *event.Event)
- func (br *Bridge) QueueRemoteEvent(login *UserLogin, evt RemoteEvent)
- func (br *Bridge) ReIDPortal(ctx context.Context, source, target networkid.PortalKey) (ReIDResult, *Portal, error)
- func (br *Bridge) SendGlobalBridgeState(state status.BridgeState)
- func (br *Bridge) Start() error
- func (br *Bridge) Stop()
- func (br *Bridge) UnlockedGetPortalByKey(ctx context.Context, key networkid.PortalKey, onlyIfExists bool) (*Portal, error)
- type BridgeName
- type BridgeStateQueue
- type ChatInfo
- type ChatInfoChange
- type ChatMember
- type ChatMemberList
- type CommandProcessor
- type ConfigValidatingNetwork
- type ContactListingNetworkAPI
- type ConvertedEdit
- type ConvertedEditPart
- type ConvertedMessage
- type ConvertedMessagePart
- type CreateChatResponse
- type DBUpgradeError
- type DirectMediableNetwork
- type DisappearLoop
- type EditHandlingNetworkAPI
- type EventSender
- type FCMPushConfig
- type FetchMessagesParams
- type FetchMessagesResponse
- type FileRestriction
- type Ghost
- func (ghost *Ghost) UpdateAvatar(ctx context.Context, avatar *Avatar) bool
- func (ghost *Ghost) UpdateContactInfo(ctx context.Context, identifiers []string, isBot *bool) bool
- func (ghost *Ghost) UpdateInfo(ctx context.Context, info *UserInfo)
- func (ghost *Ghost) UpdateInfoIfNecessary(ctx context.Context, source *UserLogin, evtType RemoteEventType)
- func (ghost *Ghost) UpdateName(ctx context.Context, name string) bool
- type GroupCreatingNetworkAPI
- type IdentifierResolvingNetworkAPI
- type LoginCompleteParams
- type LoginCookiesParams
- type LoginDisplayAndWaitParams
- type LoginDisplayType
- type LoginFlow
- type LoginInputDataField
- type LoginInputFieldType
- type LoginProcess
- type LoginProcessCookies
- type LoginProcessDisplayAndWait
- type LoginProcessUserInput
- type LoginStep
- type LoginStepType
- type LoginSubmit
- type LoginUserInputParams
- type MatrixAPI
- type MatrixCapabilities
- type MatrixConnector
- type MatrixConnectorWithServer
- type MatrixEdit
- type MatrixEventBase
- type MatrixMessage
- type MatrixMessageRemove
- type MatrixMessageResponse
- type MatrixReaction
- type MatrixReactionPreResponse
- type MatrixReactionRemove
- type MatrixReadReceipt
- type MatrixRoomAvatar
- type MatrixRoomMeta
- type MatrixRoomName
- type MatrixRoomTopic
- type MatrixTyping
- type MaxFileSizeingNetwork
- type MessageStatus
- func (ms MessageStatus) Error() string
- func (ms *MessageStatus) ToCheckpoint(evt *MessageStatusEventInfo) *status.MessageCheckpoint
- func (ms *MessageStatus) ToMSSEvent(evt *MessageStatusEventInfo) *event.BeeperMessageStatusEventContent
- func (ms *MessageStatus) ToNoticeEvent(evt *MessageStatusEventInfo) *event.MessageEventContent
- func (ms MessageStatus) Unwrap() error
- func (ms MessageStatus) WithErrorAsMessage() MessageStatus
- func (ms MessageStatus) WithErrorReason(reason event.MessageStatusReason) MessageStatus
- func (ms MessageStatus) WithIsCertain(certain bool) MessageStatus
- func (ms MessageStatus) WithMessage(msg string) MessageStatus
- func (ms MessageStatus) WithSendNotice(send bool) MessageStatus
- func (ms MessageStatus) WithStatus(status event.MessageStatus) MessageStatus
- func (ms MessageStatus) WithStep(step status.MessageCheckpointStep) MessageStatus
- type MessageStatusEventInfo
- type NetworkAPI
- type NetworkConnector
- type NetworkGeneralCapabilities
- type NetworkRoomCapabilities
- type NewLoginParams
- type OrigSender
- type Portal
- func (portal *Portal) CreateMatrixRoom(ctx context.Context, source *UserLogin, info *ChatInfo) error
- func (portal *Portal) Delete(ctx context.Context) error
- func (portal *Portal) DoBackwardsBackfill(ctx context.Context, source *UserLogin)
- func (portal *Portal) FindPreferredLogin(ctx context.Context, user *User, allowRelay bool) (*UserLogin, *database.UserPortal, error)
- func (portal *Portal) GetInitialMemberList(ctx context.Context, members *ChatMemberList, source *UserLogin, ...) (invite, functional []id.UserID, err error)
- func (portal *Portal) GetIntentFor(ctx context.Context, sender EventSender, source *UserLogin, ...) MatrixAPI
- func (portal *Portal) GetTopLevelParent() *Portal
- func (portal *Portal) ProcessChatInfoChange(ctx context.Context, sender EventSender, source *UserLogin, ...)
- func (portal *Portal) Save(ctx context.Context) error
- func (portal *Portal) SetRelay(ctx context.Context, relay *UserLogin) error
- func (portal *Portal) SyncParticipants(ctx context.Context, members *ChatMemberList, source *UserLogin, ...) error
- func (portal *Portal) UpdateAvatar(ctx context.Context, avatar *Avatar, sender MatrixAPI, ts time.Time) bool
- func (portal *Portal) UpdateBridgeInfo(ctx context.Context)
- func (portal *Portal) UpdateDisappearingSetting(ctx context.Context, setting database.DisappearingSetting, sender MatrixAPI, ...) bool
- func (portal *Portal) UpdateInfo(ctx context.Context, info *ChatInfo, source *UserLogin, sender MatrixAPI, ...)
- func (portal *Portal) UpdateName(ctx context.Context, name string, sender MatrixAPI, ts time.Time) bool
- func (portal *Portal) UpdateParent(ctx context.Context, newParent networkid.PortalID, source *UserLogin) bool
- func (portal *Portal) UpdateTopic(ctx context.Context, topic string, sender MatrixAPI, ts time.Time) bool
- type PortalInfodeprecated
- type PowerLevelChanges
- type PushConfig
- type PushType
- type PushableNetworkAPI
- type ReIDResult
- type ReactionHandlingNetworkAPI
- type ReadReceiptHandlingNetworkAPI
- type RedactionHandlingNetworkAPI
- type RemoteBackfill
- type RemoteChatInfoChange
- type RemoteChatResync
- type RemoteChatResyncBackfill
- type RemoteChatResyncWithInfo
- type RemoteEdit
- type RemoteEvent
- type RemoteEventThatMayCreatePortal
- type RemoteEventType
- type RemoteEventWithTargetMessage
- type RemoteEventWithTargetPart
- type RemoteEventWithTimestamp
- type RemoteMarkUnread
- type RemoteMessage
- type RemoteMessageRemove
- type RemotePreHandler
- type RemoteReaction
- type RemoteReactionRemove
- type RemoteReactionWithExtraContent
- type RemoteReactionWithMeta
- type RemoteReceipt
- type RemoteTyping
- type RemoteTypingWithType
- type ResolveIdentifierResponse
- type RoomAvatarHandlingNetworkAPI
- type RoomMetaEventContent
- type RoomNameHandlingNetworkAPI
- type RoomTopicHandlingNetworkAPI
- type SimpleRemoteEvent
- func (sre *SimpleRemoteEvent[T]) AddLogContext(c zerolog.Context) zerolog.Context
- func (sre *SimpleRemoteEvent[T]) ConvertEdit(ctx context.Context, portal *Portal, intent MatrixAPI, ...) (*ConvertedEdit, error)
- func (sre *SimpleRemoteEvent[T]) ConvertMessage(ctx context.Context, portal *Portal, intent MatrixAPI) (*ConvertedMessage, error)
- func (sre *SimpleRemoteEvent[T]) GetChatInfoChange(ctx context.Context) (*ChatInfoChange, error)
- func (sre *SimpleRemoteEvent[T]) GetID() networkid.MessageID
- func (sre *SimpleRemoteEvent[T]) GetPortalKey() networkid.PortalKey
- func (sre *SimpleRemoteEvent[T]) GetReactionDBMetadata() any
- func (sre *SimpleRemoteEvent[T]) GetReactionEmoji() (string, networkid.EmojiID)
- func (sre *SimpleRemoteEvent[T]) GetRemovedEmojiID() networkid.EmojiID
- func (sre *SimpleRemoteEvent[T]) GetSender() EventSender
- func (sre *SimpleRemoteEvent[T]) GetTargetMessage() networkid.MessageID
- func (sre *SimpleRemoteEvent[T]) GetTimestamp() time.Time
- func (sre *SimpleRemoteEvent[T]) GetType() RemoteEventType
- func (sre *SimpleRemoteEvent[T]) ShouldCreatePortal() bool
- type TypingHandlingNetworkAPI
- type TypingType
- type User
- func (user *User) DoublePuppet(ctx context.Context) MatrixAPI
- func (user *User) GetCachedUserLogins() []*UserLogin
- func (user *User) GetDefaultLogin() *UserLogin
- func (user *User) GetFormattedUserLogins() string
- func (user *User) GetManagementRoom(ctx context.Context) (id.RoomID, error)
- func (user *User) GetUserLoginIDs() []networkid.UserLoginID
- func (user *User) LoginDoublePuppet(ctx context.Context, token string) error
- func (user *User) LogoutDoublePuppet(ctx context.Context)
- func (user *User) NewLogin(ctx context.Context, data *database.UserLogin, params *NewLoginParams) (*UserLogin, error)
- func (user *User) Save(ctx context.Context) error
- type UserInfo
- type UserLocalPortalInfo
- type UserLogin
- func (ul *UserLogin) AddPortalToSpace(ctx context.Context, portal *Portal, userPortal *database.UserPortal) error
- func (ul *UserLogin) Delete(ctx context.Context, state status.BridgeState, logoutRemote bool)
- func (ul *UserLogin) Disconnect(done func())
- func (ul *UserLogin) GetMXID() id.UserID
- func (ul *UserLogin) GetRemoteID() string
- func (ul *UserLogin) GetRemoteName() string
- func (ul *UserLogin) GetSpaceRoom(ctx context.Context) (id.RoomID, error)
- func (ul *UserLogin) Logout(ctx context.Context)
- func (ul *UserLogin) MarkAsPreferredIn(ctx context.Context, portal *Portal) error
- func (ul *UserLogin) MarkInPortal(ctx context.Context, portal *Portal)
- func (ul *UserLogin) Save(ctx context.Context) error
- type UserSearchingNetworkAPI
- type WebPushConfig
Constants ¶
const DisappearCheckInterval = 1 * time.Hour
const PortalEventBuffer = 64
Variables ¶
var ( ErrPanicInEventHandler error = WrapErrorInStatus(errors.New("panic in event handler")).WithSendNotice(true).WithErrorAsMessage() ErrNoPortal error = WrapErrorInStatus(errors.New("room is not a portal")).WithIsCertain(true).WithSendNotice(false) ErrIgnoringReactionFromRelayedUser error = WrapErrorInStatus(errors.New("ignoring reaction event from relayed user")).WithIsCertain(true).WithSendNotice(false) ErrEditsNotSupported error = WrapErrorInStatus(errors.New("this bridge does not support edits")).WithIsCertain(true) ErrEditsNotSupportedInPortal error = WrapErrorInStatus(errors.New("edits are not allowed in this chat")).WithIsCertain(true) ErrCaptionsNotAllowed error = WrapErrorInStatus(errors.New("captions are not supported here")).WithIsCertain(true) ErrLocationMessagesNotAllowed error = WrapErrorInStatus(errors.New("location messages are not supported here")).WithIsCertain(true) ErrEditTargetTooOld error = WrapErrorInStatus(errors.New("the message is too old to be edited")).WithIsCertain(true) ErrEditTargetTooManyEdits error = WrapErrorInStatus(errors.New("the message has been edited too many times")).WithIsCertain(true) ErrReactionsNotSupported error = WrapErrorInStatus(errors.New("this bridge does not support reactions")).WithIsCertain(true) ErrRoomMetadataNotSupported error = WrapErrorInStatus(errors.New("this bridge does not support changing room metadata")).WithIsCertain(true).WithSendNotice(false) ErrRedactionsNotSupported error = WrapErrorInStatus(errors.New("this bridge does not support deleting messages")).WithIsCertain(true) ErrUnexpectedParsedContentType error = WrapErrorInStatus(errors.New("unexpected parsed content type")).WithErrorAsMessage().WithIsCertain(true).WithSendNotice(true) ErrDatabaseError error = WrapErrorInStatus(errors.New("database error")).WithMessage("internal database error").WithIsCertain(true).WithSendNotice(true) ErrTargetMessageNotFound error = WrapErrorInStatus(errors.New("target message not found")).WithErrorAsMessage().WithIsCertain(true).WithSendNotice(false) )
var ErrDirectMediaNotEnabled = errors.New("direct media is not enabled")
var ErrNotLoggedIn = errors.New("not logged in")
var Unmuted = time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)
Functions ¶
func CleanPhoneNumber ¶
Types ¶
type APNsPushConfig ¶
type APNsPushConfig struct {
BundleID string `json:"bundle_id"`
}
type Avatar ¶
type BackfillMessage ¶
type BackfillMessage struct { *ConvertedMessage Sender EventSender ID networkid.MessageID Timestamp time.Time Reactions []*BackfillReaction }
BackfillMessage is an individual message in a history pagination request.
type BackfillReaction ¶
type BackfillReaction struct { // Optional part of the message that the reaction targets. // If nil, the reaction targets the first part of the message. TargetPart *networkid.PartID // Optional timestamp for the reaction. // If unset, the reaction will have a fake timestamp that is slightly after the message timestamp. Timestamp time.Time Sender EventSender EmojiID networkid.EmojiID Emoji string ExtraContent map[string]any DBMetadata map[string]any }
BackfillReaction is an individual reaction to a message in a history pagination request.
The target message is always the BackfillMessage that contains this item. Optionally, the reaction can target a specific part by specifying TargetPart. If not specified, the first part (sorted lexicographically) is targeted.
type BackfillingNetworkAPI ¶
type BackfillingNetworkAPI interface { NetworkAPI FetchMessages(ctx context.Context, fetchParams FetchMessagesParams) (*FetchMessagesResponse, error) }
BackfillingNetworkAPI is an optional interface that network connectors can implement to support backfilling message history.
type Bridge ¶
type Bridge struct { ID networkid.BridgeID DB *database.Database Log zerolog.Logger Matrix MatrixConnector Bot MatrixAPI Network NetworkConnector Commands CommandProcessor Config *bridgeconfig.BridgeConfig DisappearLoop *DisappearLoop // contains filtered or unexported fields }
func NewBridge ¶
func NewBridge( bridgeID networkid.BridgeID, db *dbutil.Database, log zerolog.Logger, cfg *bridgeconfig.BridgeConfig, matrix MatrixConnector, network NetworkConnector, newCommandProcessor func(*Bridge) CommandProcessor, ) *Bridge
func (*Bridge) FindCachedPortalReceiver ¶
func (*Bridge) FindPortalReceiver ¶
func (*Bridge) GetAllPortalsWithMXID ¶
func (*Bridge) GetCachedUserLoginByID ¶
func (br *Bridge) GetCachedUserLoginByID(id networkid.UserLoginID) *UserLogin
func (*Bridge) GetCurrentBridgeStates ¶
func (br *Bridge) GetCurrentBridgeStates() (states []status.BridgeState)
func (*Bridge) GetExistingPortalByKey ¶
func (*Bridge) GetExistingUserByMXID ¶
func (*Bridge) GetExistingUserLoginByID ¶
func (*Bridge) GetGhostByID ¶
func (*Bridge) GetGhostByMXID ¶
func (*Bridge) GetPortalByKey ¶
func (*Bridge) GetPortalByMXID ¶
func (*Bridge) GetUserByMXID ¶
func (*Bridge) GetUserLoginsInPortal ¶
func (*Bridge) NewBridgeStateQueue ¶
func (br *Bridge) NewBridgeStateQueue(user status.BridgeStateFiller) *BridgeStateQueue
func (*Bridge) QueueMatrixEvent ¶
func (*Bridge) QueueRemoteEvent ¶
func (br *Bridge) QueueRemoteEvent(login *UserLogin, evt RemoteEvent)
func (*Bridge) ReIDPortal ¶
func (*Bridge) SendGlobalBridgeState ¶
func (br *Bridge) SendGlobalBridgeState(state status.BridgeState)
type BridgeName ¶
type BridgeName struct { // The displayname of the network, e.g. `Discord` DisplayName string // The URL to the website of the network, e.g. `https://discord.com` NetworkURL string // The icon of the network as a mxc:// URI NetworkIcon id.ContentURIString // An identifier uniquely identifying the network, e.g. `discord` NetworkID string // An identifier uniquely identifying the bridge software. // The Go import path is a good choice here (e.g. github.com/octocat/discordbridge) BeeperBridgeType string // The default appservice port to use in the example config, defaults to 8080 if unset // Official mautrix bridges will use ports defined in https://mau.fi/ports DefaultPort uint16 // The default command prefix to use in the example config, defaults to NetworkID if unset. Must include the ! prefix. DefaultCommandPrefix string }
BridgeName contains information about the network that a connector bridges to.
func (BridgeName) AsBridgeInfoSection ¶
func (bn BridgeName) AsBridgeInfoSection() event.BridgeInfoSection
type BridgeStateQueue ¶
type BridgeStateQueue struct {
// contains filtered or unexported fields
}
func (*BridgeStateQueue) Destroy ¶
func (bsq *BridgeStateQueue) Destroy()
func (*BridgeStateQueue) GetPrev ¶
func (bsq *BridgeStateQueue) GetPrev() status.BridgeState
func (*BridgeStateQueue) Send ¶
func (bsq *BridgeStateQueue) Send(state status.BridgeState)
func (*BridgeStateQueue) SetPrev ¶
func (bsq *BridgeStateQueue) SetPrev(prev status.BridgeState)
type ChatInfo ¶
type ChatInfo struct { Name *string Topic *string Avatar *Avatar Members *ChatMemberList JoinRule *event.JoinRulesEventContent Type *database.RoomType Disappear *database.DisappearingSetting ParentID *networkid.PortalID UserLocal *UserLocalPortalInfo ExtraUpdates func(context.Context, *Portal) bool }
type ChatInfoChange ¶
type ChatInfoChange struct { // The chat info that changed. Any fields that did not change can be left as nil. ChatInfo *ChatInfo // A list of member changes. // This list should only include changes, not the whole member list. // To resync the whole list, use the field inside ChatInfo. MemberChanges *ChatMemberList }
type ChatMember ¶
type ChatMember struct { EventSender Membership event.Membership Nickname string PowerLevel int PrevMembership event.Membership }
type ChatMemberList ¶
type ChatMemberList struct { // Whether this is the full member list. // If true, any extra members not listed here will be removed from the portal. IsFull bool // Should the bridge call IsThisUser for every member in the list? // This should be used when SenderLogin can't be filled accurately. CheckAllLogins bool // The total number of members in the chat, regardless of how many of those members are included in Members. TotalMemberCount int Members []ChatMember PowerLevels *PowerLevelChanges }
type CommandProcessor ¶
type ConfigValidatingNetwork ¶
type ConfigValidatingNetwork interface { NetworkConnector ValidateConfig() error }
ConfigValidatingNetwork is an optional interface that network connectors can implement to validate config fields before the bridge is started.
When the ValidateConfig method is called, the config data will already be unmarshaled into the object returned by [NetworkConnector.GetConfig].
This mechanism is usually used to refuse bridge startup if a mandatory field has an invalid value.
type ContactListingNetworkAPI ¶
type ContactListingNetworkAPI interface { NetworkAPI GetContactList(ctx context.Context) ([]*ResolveIdentifierResponse, error) }
ContactListingNetworkAPI is an optional interface that network connectors can implement to provide the user's contact list.
type ConvertedEdit ¶
type ConvertedEdit struct { ModifiedParts []*ConvertedEditPart DeletedParts []*database.Message }
type ConvertedEditPart ¶
type ConvertedEditPart struct { Part *database.Message Type event.Type // The Content and Extra fields will be put inside `m.new_content` automatically. // SetEdit must NOT be called by the network connector. Content *event.MessageEventContent Extra map[string]any // TopLevelExtra can be used to specify custom fields at the top level of the content rather than inside `m.new_content`. TopLevelExtra map[string]any }
type ConvertedMessage ¶
type ConvertedMessage struct { ReplyTo *networkid.MessageOptionalPartID ThreadRoot *networkid.MessageID Parts []*ConvertedMessagePart Disappear database.DisappearingSetting }
func (*ConvertedMessage) MergeCaption ¶
func (cm *ConvertedMessage) MergeCaption() bool
type ConvertedMessagePart ¶
type ConvertedMessagePart struct { ID networkid.PartID Type event.Type Content *event.MessageEventContent Extra map[string]any DBMetadata any }
func MergeCaption ¶
func MergeCaption(textPart, mediaPart *ConvertedMessagePart) *ConvertedMessagePart
func (*ConvertedMessagePart) ToEditPart ¶
func (cmp *ConvertedMessagePart) ToEditPart(part *database.Message) *ConvertedEditPart
type CreateChatResponse ¶
type DBUpgradeError ¶
func (DBUpgradeError) Error ¶
func (e DBUpgradeError) Error() string
func (DBUpgradeError) Unwrap ¶
func (e DBUpgradeError) Unwrap() error
type DirectMediableNetwork ¶
type DirectMediableNetwork interface { NetworkConnector SetUseDirectMedia() Download(ctx context.Context, mediaID networkid.MediaID) (mediaproxy.GetMediaResponse, error) }
DirectMediableNetwork is an optional interface that network connectors can implement to support direct media access.
If the Matrix connector has direct media enabled, SetUseDirectMedia will be called before the Start method of the network connector. Download will then be called whenever someone wants to download a direct media `mxc://` URI which was generated by calling GenerateContentURI on the Matrix connector.
type DisappearLoop ¶
func (*DisappearLoop) Add ¶
func (dl *DisappearLoop) Add(ctx context.Context, dm *database.DisappearingMessage)
func (*DisappearLoop) Start ¶
func (dl *DisappearLoop) Start()
func (*DisappearLoop) StartAll ¶
func (dl *DisappearLoop) StartAll(ctx context.Context, roomID id.RoomID)
func (*DisappearLoop) Stop ¶
func (dl *DisappearLoop) Stop()
type EditHandlingNetworkAPI ¶
type EditHandlingNetworkAPI interface { NetworkAPI // HandleMatrixEdit is called when a previously bridged message is edited in a portal room. // The central bridge module will save the [*database.Message] after this function returns, // so the network connector is allowed to mutate the provided object. HandleMatrixEdit(ctx context.Context, msg *MatrixEdit) error }
EditHandlingNetworkAPI is an optional interface that network connectors can implement to handle message edits.
type EventSender ¶
type EventSender struct { IsFromMe bool SenderLogin networkid.UserLoginID Sender networkid.UserID }
type FCMPushConfig ¶
type FCMPushConfig struct {
SenderID string `json:"sender_id"`
}
type FetchMessagesParams ¶
type FetchMessagesParams struct { // The portal to fetch messages in. Always present. Portal *Portal // When fetching messages inside a thread, the ID of the thread. ThreadRoot networkid.MessageID // Whether to fetch new messages instead of old ones. Forward bool // The oldest known message in the thread or the portal. If Forward is true, this is the newest known message instead. // If the portal doesn't have any bridged messages, this will be nil. AnchorMessage *database.Message // The cursor returned by the previous call to FetchMessages with the same portal and thread root. // This will not be present in Forward calls. Cursor networkid.PaginationCursor // The preferred number of messages to return. The returned batch can be bigger or smaller // without any side effects, but the network connector should aim for this number. Count int }
FetchMessagesParams contains the parameters for a message history pagination request.
type FetchMessagesResponse ¶
type FetchMessagesResponse struct { // The messages to backfill. Messages should always be sorted in chronological order (oldest to newest). Messages []*BackfillMessage // The next cursor to use for fetching more messages. Cursor networkid.PaginationCursor // Whether there are more messages that can be backfilled. // This field is required. If it is false, FetchMessages will not be called again. HasMore bool // Whether the batch contains new messages rather than old ones. // Cursor, HasMore and the progress fields will be ignored when this is present. Forward bool // When sending forward backfill (or the first batch in a room), this field can be set // to mark the messages as read immediately after backfilling. MarkRead bool // Approximate backfill progress as a number between 0 and 1. ApproxProgress float64 // Approximate number of messages remaining that can be backfilled. ApproxRemainingCount int // Approximate total number of messages in the chat. ApproxTotalCount int }
FetchMessagesResponse contains the response for a message history pagination request.
type FileRestriction ¶
type Ghost ¶
func (*Ghost) UpdateAvatar ¶
func (*Ghost) UpdateContactInfo ¶
func (*Ghost) UpdateInfoIfNecessary ¶
func (ghost *Ghost) UpdateInfoIfNecessary(ctx context.Context, source *UserLogin, evtType RemoteEventType)
type GroupCreatingNetworkAPI ¶
type GroupCreatingNetworkAPI interface { IdentifierResolvingNetworkAPI CreateGroup(ctx context.Context, name string, users ...networkid.UserID) (*CreateChatResponse, error) }
type IdentifierResolvingNetworkAPI ¶
type IdentifierResolvingNetworkAPI interface { NetworkAPI // ResolveIdentifier is called when the user wants to start a new chat. // This can happen via the `resolve-identifier` or `start-chat` bridge bot commands, // or the corresponding provisioning API endpoints. ResolveIdentifier(ctx context.Context, identifier string, createChat bool) (*ResolveIdentifierResponse, error) }
IdentifierResolvingNetworkAPI is an optional interface that network connectors can implement to support starting new direct chats.
type LoginCompleteParams ¶
type LoginCompleteParams struct { UserLoginID networkid.UserLoginID `json:"user_login_id"` UserLogin *UserLogin `json:"-"` }
type LoginCookiesParams ¶
type LoginCookiesParams struct { URL string `json:"url"` UserAgent string `json:"user_agent,omitempty"` CookieDomain string `json:"cookie_domain,omitempty"` CookieKeys []string `json:"cookie_keys,omitempty"` LocalStorageKeys []string `json:"local_storage_keys,omitempty"` SpecialKeys []string `json:"special_keys,omitempty"` SpecialExtractJS string `json:"special_extract_js,omitempty"` }
type LoginDisplayAndWaitParams ¶
type LoginDisplayAndWaitParams struct { // The type of thing to display (QR, emoji or text code) Type LoginDisplayType `json:"type"` // The thing to display (raw data for QR, unicode emoji for emoji, plain string for code, omitted for nothing) Data string `json:"data,omitempty"` // An image containing the thing to display. If present, this is recommended over using data directly. // For emojis, the URL to the canonical image representation of the emoji ImageURL string `json:"image_url,omitempty"` }
type LoginDisplayType ¶
type LoginDisplayType string
const ( LoginDisplayTypeQR LoginDisplayType = "qr" LoginDisplayTypeEmoji LoginDisplayType = "emoji" LoginDisplayTypeCode LoginDisplayType = "code" LoginDisplayTypeNothing LoginDisplayType = "nothing" )
type LoginInputDataField ¶
type LoginInputDataField struct { // The type of input field as a hint for the client. Type LoginInputFieldType `json:"type"` // The ID of the field to be used as the key in the map that is submitted to the connector. ID string `json:"id"` // The name of the field shown to the user. Name string `json:"name"` // The description of the field shown to the user. Description string `json:"description"` // A regex pattern that the client can use to validate input client-side. Pattern string `json:"pattern,omitempty"` // A function that validates the input and optionally cleans it up before it's submitted to the connector. Validate func(string) (string, error) `json:"-"` }
func (*LoginInputDataField) FillDefaultValidate ¶
func (f *LoginInputDataField) FillDefaultValidate()
type LoginInputFieldType ¶
type LoginInputFieldType string
const ( LoginInputFieldTypeUsername LoginInputFieldType = "username" LoginInputFieldTypePassword LoginInputFieldType = "password" LoginInputFieldTypePhoneNumber LoginInputFieldType = "phone_number" LoginInputFieldTypeEmail LoginInputFieldType = "email" LoginInputFieldType2FACode LoginInputFieldType = "2fa_code" )
type LoginProcess ¶
type LoginProcess interface { // Start starts the process and returns the first step. // // For example, a network using QR login may connect to the network, fetch a QR code, // and return a DisplayAndWait-type step. // // This will only ever be called once. Start(ctx context.Context) (*LoginStep, error) // Cancel stops the login process and cleans up any resources. // No other methods will be called after cancel. // // Cancel will not be called if any other method returned an error: // errors are always treated as fatal and the process is assumed to be automatically cancelled. Cancel() }
LoginProcess represents a single occurrence of a user logging into the remote network.
type LoginProcessCookies ¶
type LoginProcessDisplayAndWait ¶
type LoginProcessDisplayAndWait interface { LoginProcess Wait(ctx context.Context) (*LoginStep, error) }
type LoginProcessUserInput ¶
type LoginStep ¶
type LoginStep struct { // The type of login step Type LoginStepType `json:"type"` // A unique ID for this step. The ID should be same for every login using the same flow, // but it should be different for different bridges and step types. // // For example, Telegram's QR scan followed by a 2-factor password // might use the IDs `fi.mau.telegram.qr` and `fi.mau.telegram.2fa_password`. StepID string `json:"step_id"` // Instructions contains human-readable instructions for completing the login step. Instructions string `json:"instructions"` DisplayAndWaitParams *LoginDisplayAndWaitParams `json:"display_and_wait,omitempty"` CookiesParams *LoginCookiesParams `json:"cookies,omitempty"` UserInputParams *LoginUserInputParams `json:"user_input,omitempty"` CompleteParams *LoginCompleteParams `json:"complete,omitempty"` }
type LoginStepType ¶
type LoginStepType string
const ( LoginStepTypeUserInput LoginStepType = "user_input" LoginStepTypeCookies LoginStepType = "cookies" LoginStepTypeDisplayAndWait LoginStepType = "display_and_wait" LoginStepTypeComplete LoginStepType = "complete" )
type LoginSubmit ¶
type LoginSubmit struct { }
type LoginUserInputParams ¶
type LoginUserInputParams struct { // The fields that the user needs to fill in. Fields []LoginInputDataField `json:"fields"` }
type MatrixAPI ¶
type MatrixAPI interface { GetMXID() id.UserID SendMessage(ctx context.Context, roomID id.RoomID, eventType event.Type, content *event.Content, ts time.Time) (*mautrix.RespSendEvent, error) SendState(ctx context.Context, roomID id.RoomID, eventType event.Type, stateKey string, content *event.Content, ts time.Time) (*mautrix.RespSendEvent, error) MarkRead(ctx context.Context, roomID id.RoomID, eventID id.EventID, ts time.Time) error MarkUnread(ctx context.Context, roomID id.RoomID, unread bool) error MarkTyping(ctx context.Context, roomID id.RoomID, typingType TypingType, timeout time.Duration) error DownloadMedia(ctx context.Context, uri id.ContentURIString, file *event.EncryptedFileInfo) ([]byte, error) UploadMedia(ctx context.Context, roomID id.RoomID, data []byte, fileName, mimeType string) (url id.ContentURIString, file *event.EncryptedFileInfo, err error) SetDisplayName(ctx context.Context, name string) error SetAvatarURL(ctx context.Context, avatarURL id.ContentURIString) error SetExtraProfileMeta(ctx context.Context, data any) error CreateRoom(ctx context.Context, req *mautrix.ReqCreateRoom) (id.RoomID, error) DeleteRoom(ctx context.Context, roomID id.RoomID, puppetsOnly bool) error InviteUser(ctx context.Context, roomID id.RoomID, userID id.UserID) error EnsureJoined(ctx context.Context, roomID id.RoomID) error EnsureInvited(ctx context.Context, roomID id.RoomID, userID id.UserID) error TagRoom(ctx context.Context, roomID id.RoomID, tag event.RoomTag, isTagged bool) error MuteRoom(ctx context.Context, roomID id.RoomID, until time.Time) error }
type MatrixCapabilities ¶
type MatrixConnector ¶
type MatrixConnector interface { Init(*Bridge) Start(ctx context.Context) error Stop() GetCapabilities() *MatrixCapabilities ParseGhostMXID(userID id.UserID) (networkid.UserID, bool) GhostIntent(userID networkid.UserID) MatrixAPI NewUserIntent(ctx context.Context, userID id.UserID, accessToken string) (MatrixAPI, string, error) BotIntent() MatrixAPI SendBridgeStatus(ctx context.Context, state *status.BridgeState) error SendMessageStatus(ctx context.Context, status *MessageStatus, evt *MessageStatusEventInfo) GenerateContentURI(ctx context.Context, mediaID networkid.MediaID) (id.ContentURIString, error) GetPowerLevels(ctx context.Context, roomID id.RoomID) (*event.PowerLevelsEventContent, error) GetMembers(ctx context.Context, roomID id.RoomID) (map[id.UserID]*event.MemberEventContent, error) GetMemberInfo(ctx context.Context, roomID id.RoomID, userID id.UserID) (*event.MemberEventContent, error) BatchSend(ctx context.Context, roomID id.RoomID, req *mautrix.ReqBeeperBatchSend) (*mautrix.RespBeeperBatchSend, error) GenerateDeterministicEventID(roomID id.RoomID, portalKey networkid.PortalKey, messageID networkid.MessageID, partID networkid.PartID) id.EventID ServerName() string }
type MatrixEdit ¶
type MatrixEdit struct { MatrixEventBase[*event.MessageEventContent] EditTarget *database.Message }
type MatrixEventBase ¶
type MatrixEventBase[ContentType any] struct { // The raw event being bridged. Event *event.Event // The parsed content struct of the event. Custom fields can be found in Event.Content.Raw. Content ContentType // The room where the event happened. Portal *Portal // The original sender user ID. Only present in case the event is being relayed (and Sender is not the same user). OrigSender *OrigSender }
type MatrixMessage ¶
type MatrixMessage struct { MatrixEventBase[*event.MessageEventContent] ThreadRoot *database.Message ReplyTo *database.Message }
type MatrixMessageRemove ¶
type MatrixMessageRemove struct { MatrixEventBase[*event.RedactionEventContent] TargetMessage *database.Message }
type MatrixMessageResponse ¶
type MatrixReaction ¶
type MatrixReaction struct { MatrixEventBase[*event.ReactionEventContent] TargetMessage *database.Message PreHandleResp *MatrixReactionPreResponse // When MaxReactions is >0 in the pre-response, this is the list of previous reactions that should be preserved. ExistingReactionsToKeep []*database.Reaction }
type MatrixReactionRemove ¶
type MatrixReactionRemove struct { MatrixEventBase[*event.RedactionEventContent] TargetReaction *database.Reaction }
type MatrixReadReceipt ¶
type MatrixReadReceipt struct { Portal *Portal // The event ID that the receipt is targeting EventID id.EventID // The exact message that was read. This may be nil if the event ID isn't a message. ExactMessage *database.Message // The timestamp that the user has read up to. This is either the timestamp of the message // (if one is present) or the timestamp of the receipt. ReadUpTo time.Time // The ReadUpTo timestamp of the previous message LastRead time.Time // The receipt metadata. Receipt event.ReadReceipt }
type MatrixRoomAvatar ¶
type MatrixRoomAvatar = MatrixRoomMeta[*event.RoomAvatarEventContent]
type MatrixRoomMeta ¶
type MatrixRoomMeta[ContentType RoomMetaEventContent] struct { MatrixEventBase[ContentType] PrevContent ContentType }
type MatrixRoomName ¶
type MatrixRoomName = MatrixRoomMeta[*event.RoomNameEventContent]
type MatrixRoomTopic ¶
type MatrixRoomTopic = MatrixRoomMeta[*event.TopicEventContent]
type MatrixTyping ¶
type MatrixTyping struct { Portal *Portal IsTyping bool Type TypingType }
type MaxFileSizeingNetwork ¶
type MaxFileSizeingNetwork interface { NetworkConnector SetMaxFileSize(maxSize int64) }
MaxFileSizeingNetwork is an optional interface that network connectors can implement to find out the maximum file size that can be uploaded to Matrix.
The SetMaxFileSize will be called asynchronously soon after startup. Before the function is called, the connector may assume a default limit of 50 MiB.
type MessageStatus ¶
type MessageStatus struct { Step status.MessageCheckpointStep RetryNum int Status event.MessageStatus ErrorReason event.MessageStatusReason DeliveredTo []id.UserID InternalError error // Internal error to be tracked in message checkpoints Message string // Human-readable message shown to users ErrorAsMessage bool IsCertain bool SendNotice bool DisableMSS bool }
func WrapErrorInStatus ¶
func WrapErrorInStatus(err error) MessageStatus
func (MessageStatus) Error ¶
func (ms MessageStatus) Error() string
func (*MessageStatus) ToCheckpoint ¶
func (ms *MessageStatus) ToCheckpoint(evt *MessageStatusEventInfo) *status.MessageCheckpoint
func (*MessageStatus) ToMSSEvent ¶
func (ms *MessageStatus) ToMSSEvent(evt *MessageStatusEventInfo) *event.BeeperMessageStatusEventContent
func (*MessageStatus) ToNoticeEvent ¶
func (ms *MessageStatus) ToNoticeEvent(evt *MessageStatusEventInfo) *event.MessageEventContent
func (MessageStatus) Unwrap ¶
func (ms MessageStatus) Unwrap() error
func (MessageStatus) WithErrorAsMessage ¶
func (ms MessageStatus) WithErrorAsMessage() MessageStatus
func (MessageStatus) WithErrorReason ¶
func (ms MessageStatus) WithErrorReason(reason event.MessageStatusReason) MessageStatus
func (MessageStatus) WithIsCertain ¶
func (ms MessageStatus) WithIsCertain(certain bool) MessageStatus
func (MessageStatus) WithMessage ¶
func (ms MessageStatus) WithMessage(msg string) MessageStatus
func (MessageStatus) WithSendNotice ¶
func (ms MessageStatus) WithSendNotice(send bool) MessageStatus
func (MessageStatus) WithStatus ¶
func (ms MessageStatus) WithStatus(status event.MessageStatus) MessageStatus
func (MessageStatus) WithStep ¶
func (ms MessageStatus) WithStep(step status.MessageCheckpointStep) MessageStatus
type MessageStatusEventInfo ¶
type MessageStatusEventInfo struct { RoomID id.RoomID EventID id.EventID EventType event.Type MessageType event.MessageType Sender id.UserID ThreadRoot id.EventID }
func StatusEventInfoFromEvent ¶
func StatusEventInfoFromEvent(evt *event.Event) *MessageStatusEventInfo
type NetworkAPI ¶
type NetworkAPI interface { // Connect is called to actually connect to the remote network. // If there's no persistent connection, this may just check access token validity, or even do nothing at all. Connect(ctx context.Context) error // Disconnect should disconnect from the remote network. // A clean disconnection is preferred, but it should not take too long. Disconnect() // IsLoggedIn should return whether the access tokens in this NetworkAPI are valid. // This should not do any IO operations, it should only return cached data which is updated elsewhere. IsLoggedIn() bool // LogoutRemote should invalidate the access tokens in this NetworkAPI if possible // and disconnect from the remote network. LogoutRemote(ctx context.Context) // IsThisUser should return whether the given remote network user ID is the same as this login. // This is used when the bridge wants to convert a user login ID to a user ID. IsThisUser(ctx context.Context, userID networkid.UserID) bool // GetChatInfo returns info for a given chat. Any fields that are nil will be ignored and not processed at all, // while empty strings will change the relevant value in the room to be an empty string. // For example, a nil name will mean the room name is not changed, while an empty string name will remove the name. GetChatInfo(ctx context.Context, portal *Portal) (*ChatInfo, error) // GetUserInfo returns info for a given user. Like chat info, fields can be nil to skip them. GetUserInfo(ctx context.Context, ghost *Ghost) (*UserInfo, error) // GetCapabilities returns the bridging capabilities in a given room. // This can simply return a static list if the remote network has no per-chat capability differences, // but all calls will include the portal, because some networks do have per-chat differences. GetCapabilities(ctx context.Context, portal *Portal) *NetworkRoomCapabilities // HandleMatrixMessage is called when a message is sent from Matrix in an existing portal room. // This function should convert the message as appropriate, send it over to the remote network, // and return the info so the central bridge can store it in the database. // // This is only called for normal non-edit messages. For other types of events, see the optional extra interfaces (`XHandlingNetworkAPI`). HandleMatrixMessage(ctx context.Context, msg *MatrixMessage) (message *MatrixMessageResponse, err error) }
NetworkAPI is an interface representing a remote network client for a single user login.
Implementations of this interface are stored in [UserLogin.Client]. The [NetworkConnector.LoadUserLogin] method is responsible for filling the Client field with a NetworkAPI.
type NetworkConnector ¶
type NetworkConnector interface { // Init is called when the bridge is initialized. The connector should store the bridge instance for later use. // This should not do any network calls or other blocking operations. Init(*Bridge) // Start is called when the bridge is starting. // The connector should do any non-user-specific startup actions necessary. // User logins will be loaded separately, so the connector should not load them here. Start(context.Context) error // GetName returns the name of the bridge and some additional metadata, // which is used to fill `m.bridge` events among other things. // // The first call happens *before* the config is loaded, because the data here is also used to // fill parts of the example config (like the default username template and bot localpart). // The output can still be adjusted based on config variables, but the function must have // default values when called without a config. GetName() BridgeName // GetDBMetaTypes returns struct types that are used to store connector-specific metadata in various tables. // All fields are optional. If a field isn't provided, then the corresponding table will have no custom metadata. // This will be called before Init, it should have a hardcoded response. GetDBMetaTypes() database.MetaTypes // GetCapabilities returns the general capabilities of the network connector. // Note that most capabilities are scoped to rooms and are returned by [NetworkAPI.GetCapabilities] instead. GetCapabilities() *NetworkGeneralCapabilities // GetConfig returns all the parts of the network connector's config file. Specifically: // - example: a string containing an example config file // - data: an interface to unmarshal the actual config into // - upgrader: a config upgrader to ensure all fields are present and to do any migrations from old configs GetConfig() (example string, data any, upgrader configupgrade.Upgrader) // LoadUserLogin is called when a UserLogin is loaded from the database in order to fill the [UserLogin.Client] field. // // This is called within the bridge's global cache lock, so it must not do any slow operations, // such as connecting to the network. Instead, connecting should happen when [NetworkAPI.Connect] is called later. LoadUserLogin(ctx context.Context, login *UserLogin) error // GetLoginFlows returns a list of login flows that the network supports. GetLoginFlows() []LoginFlow // CreateLogin is called when a user wants to log in to the network. // // This should generally not do any work, it should just return a LoginProcess that remembers // the user and will execute the requested flow. The actual work should start when [LoginProcess.Start] is called. CreateLogin(ctx context.Context, user *User, flowID string) (LoginProcess, error) }
NetworkConnector is the main interface that a network connector must implement.
type NetworkGeneralCapabilities ¶
type NetworkGeneralCapabilities struct { // Does the network connector support disappearing messages? // This flag enables the message disappearing loop in the bridge. DisappearingMessages bool // Should the bridge re-request user info on incoming messages even if the ghost already has info? // By default, info is only requested for ghosts with no name, and other updating is left to events. AggressiveUpdateInfo bool }
type NetworkRoomCapabilities ¶
type NetworkRoomCapabilities struct { FormattedText bool UserMentions bool RoomMentions bool LocationMessages bool Captions bool MaxTextLength int MaxCaptionLength int Threads bool Replies bool Edits bool EditMaxCount int EditMaxAge time.Duration Deletes bool DeleteMaxAge time.Duration DefaultFileRestriction *FileRestriction Files map[event.MessageType]FileRestriction ReadReceipts bool Reactions bool ReactionCount int AllowedReactions []string }
type NewLoginParams ¶
type OrigSender ¶
type OrigSender struct { User *User event.MemberEventContent }
type Portal ¶
type Portal struct { *database.Portal Bridge *Bridge Log zerolog.Logger Parent *Portal Relay *UserLogin // contains filtered or unexported fields }
func (*Portal) CreateMatrixRoom ¶
func (*Portal) DoBackwardsBackfill ¶
func (*Portal) FindPreferredLogin ¶
func (*Portal) GetInitialMemberList ¶
func (portal *Portal) GetInitialMemberList(ctx context.Context, members *ChatMemberList, source *UserLogin, pl *event.PowerLevelsEventContent) (invite, functional []id.UserID, err error)
func (*Portal) GetIntentFor ¶
func (portal *Portal) GetIntentFor(ctx context.Context, sender EventSender, source *UserLogin, evtType RemoteEventType) MatrixAPI
func (*Portal) GetTopLevelParent ¶
func (*Portal) ProcessChatInfoChange ¶
func (portal *Portal) ProcessChatInfoChange(ctx context.Context, sender EventSender, source *UserLogin, change *ChatInfoChange, ts time.Time)
func (*Portal) SyncParticipants ¶
func (*Portal) UpdateAvatar ¶
func (*Portal) UpdateBridgeInfo ¶
func (*Portal) UpdateDisappearingSetting ¶
func (*Portal) UpdateInfo ¶
func (*Portal) UpdateName ¶
func (*Portal) UpdateParent ¶
type PortalInfo
deprecated
type PortalInfo = ChatInfo
Deprecated: Renamed to ChatInfo
type PowerLevelChanges ¶
type PowerLevelChanges struct { Events map[event.Type]int UsersDefault *int EventsDefault *int StateDefault *int Invite *int Kick *int Ban *int Redact *int Custom func(*event.PowerLevelsEventContent) bool }
func (*PowerLevelChanges) Apply ¶
func (plc *PowerLevelChanges) Apply(content *event.PowerLevelsEventContent) (changed bool)
type PushConfig ¶
type PushConfig struct { Web *WebPushConfig `json:"web,omitempty"` FCM *FCMPushConfig `json:"fcm,omitempty"` APNs *APNsPushConfig `json:"apns,omitempty"` }
type PushableNetworkAPI ¶
type ReIDResult ¶
type ReIDResult int
const ( ReIDResultError ReIDResult = iota ReIDResultNoOp ReIDResultSourceDeleted ReIDResultSourceReIDd ReIDResultTargetDeletedAndSourceReIDd ReIDResultSourceTombstonedIntoTarget )
type ReactionHandlingNetworkAPI ¶
type ReactionHandlingNetworkAPI interface { NetworkAPI // PreHandleMatrixReaction is called as the first step of handling a reaction. It returns the emoji ID, // sender user ID and max reaction count to allow the central bridge module to de-duplicate the reaction // if appropriate. PreHandleMatrixReaction(ctx context.Context, msg *MatrixReaction) (MatrixReactionPreResponse, error) // HandleMatrixReaction is called after confirming that the reaction is not a duplicate. // This is the method that should actually send the reaction to the remote network. // The returned [database.Reaction] object may be empty: the central bridge module already has // all the required fields and will fill them automatically if they're empty. However, network // connectors are allowed to set fields themselves if any extra fields are necessary. HandleMatrixReaction(ctx context.Context, msg *MatrixReaction) (reaction *database.Reaction, err error) // HandleMatrixReactionRemove is called when a redaction event is received pointing at a previously // bridged reaction. The network connector should remove the reaction from the remote network. HandleMatrixReactionRemove(ctx context.Context, msg *MatrixReactionRemove) error }
ReactionHandlingNetworkAPI is an optional interface that network connectors can implement to handle message reactions.
type ReadReceiptHandlingNetworkAPI ¶
type ReadReceiptHandlingNetworkAPI interface { NetworkAPI // HandleMatrixReadReceipt is called when a read receipt is sent in a portal room. // This will be called even if the target message is not a bridged message. // Network connectors must gracefully handle [MatrixReadReceipt.ExactMessage] being nil. // The exact handling is up to the network connector. HandleMatrixReadReceipt(ctx context.Context, msg *MatrixReadReceipt) error }
ReadReceiptHandlingNetworkAPI is an optional interface that network connectors can implement to handle read receipts.
type RedactionHandlingNetworkAPI ¶
type RedactionHandlingNetworkAPI interface { NetworkAPI // HandleMatrixMessageRemove is called when a previously bridged message is deleted in a portal room. HandleMatrixMessageRemove(ctx context.Context, msg *MatrixMessageRemove) error }
RedactionHandlingNetworkAPI is an optional interface that network connectors can implement to handle message deletions.
type RemoteBackfill ¶
type RemoteBackfill interface { RemoteEvent GetBackfillData(ctx context.Context, portal *Portal) (*FetchMessagesResponse, error) }
type RemoteChatInfoChange ¶
type RemoteChatInfoChange interface { RemoteEvent GetChatInfoChange(ctx context.Context) (*ChatInfoChange, error) }
type RemoteChatResync ¶
type RemoteChatResync interface { RemoteEvent }
type RemoteEdit ¶
type RemoteEdit interface { RemoteEventWithTargetMessage ConvertEdit(ctx context.Context, portal *Portal, intent MatrixAPI, existing []*database.Message) (*ConvertedEdit, error) }
type RemoteEvent ¶
type RemoteEvent interface { GetType() RemoteEventType GetPortalKey() networkid.PortalKey AddLogContext(c zerolog.Context) zerolog.Context GetSender() EventSender }
RemoteEvent represents a single event from the remote network, such as a message or a reaction.
When a NetworkAPI receives an event from the remote network, it should convert it into a RemoteEvent and pass it to the bridge for processing using Bridge.QueueRemoteEvent.
type RemoteEventThatMayCreatePortal ¶
type RemoteEventThatMayCreatePortal interface { RemoteEvent ShouldCreatePortal() bool }
type RemoteEventType ¶
type RemoteEventType int
const ( RemoteEventUnknown RemoteEventType = iota RemoteEventMessage RemoteEventEdit RemoteEventReaction RemoteEventReactionRemove RemoteEventMessageRemove RemoteEventReadReceipt RemoteEventDeliveryReceipt RemoteEventMarkUnread RemoteEventTyping RemoteEventChatInfoChange RemoteEventChatResync RemoteEventBackfill )
func (RemoteEventType) String ¶
func (ret RemoteEventType) String() string
type RemoteEventWithTargetMessage ¶
type RemoteEventWithTargetMessage interface { RemoteEvent GetTargetMessage() networkid.MessageID }
type RemoteEventWithTargetPart ¶
type RemoteEventWithTargetPart interface { RemoteEventWithTargetMessage GetTargetMessagePart() networkid.PartID }
type RemoteEventWithTimestamp ¶
type RemoteEventWithTimestamp interface { RemoteEvent GetTimestamp() time.Time }
type RemoteMarkUnread ¶
type RemoteMarkUnread interface { RemoteEvent GetUnread() bool }
type RemoteMessage ¶
type RemoteMessage interface { RemoteEvent GetID() networkid.MessageID ConvertMessage(ctx context.Context, portal *Portal, intent MatrixAPI) (*ConvertedMessage, error) }
type RemoteMessageRemove ¶
type RemoteMessageRemove interface { RemoteEventWithTargetMessage }
type RemotePreHandler ¶
type RemotePreHandler interface { RemoteEvent PreHandle(ctx context.Context, portal *Portal) }
type RemoteReaction ¶
type RemoteReaction interface { RemoteEventWithTargetMessage GetReactionEmoji() (string, networkid.EmojiID) }
type RemoteReactionRemove ¶
type RemoteReactionRemove interface { RemoteEventWithTargetMessage GetRemovedEmojiID() networkid.EmojiID }
type RemoteReactionWithExtraContent ¶
type RemoteReactionWithExtraContent interface { RemoteReaction GetReactionExtraContent() map[string]any }
type RemoteReactionWithMeta ¶
type RemoteReactionWithMeta interface { RemoteReaction GetReactionDBMetadata() any }
type RemoteReceipt ¶
type RemoteTyping ¶
type RemoteTyping interface { RemoteEvent GetTimeout() time.Duration }
type RemoteTypingWithType ¶
type RemoteTypingWithType interface { RemoteTyping GetTypingType() TypingType }
type ResolveIdentifierResponse ¶
type ResolveIdentifierResponse struct { // Ghost is the ghost of the user that the identifier resolves to. // This field should be set whenever possible. However, it is not required, // and the central bridge module will not try to create a ghost if it is not set. Ghost *Ghost // UserID is the user ID of the user that the identifier resolves to. UserID networkid.UserID // UserInfo contains the info of the user that the identifier resolves to. // If both this and the Ghost field are set, the central bridge module will // automatically update the ghost's info with the data here. UserInfo *UserInfo // Chat contains info about the direct chat with the resolved user. // This field is required when createChat is true in the ResolveIdentifier call, // and optional otherwise. Chat *CreateChatResponse }
type RoomAvatarHandlingNetworkAPI ¶
type RoomAvatarHandlingNetworkAPI interface { NetworkAPI // HandleMatrixRoomAvatar is called when the avatar of a portal room is changed. // This method should update the AvatarID, AvatarHash and AvatarMXC fields // with the new avatar details and return true if the change was successful. // If the change is not successful, then the fields should not be updated. HandleMatrixRoomAvatar(ctx context.Context, msg *MatrixRoomAvatar) (bool, error) }
RoomAvatarHandlingNetworkAPI is an optional interface that network connectors can implement to handle room avatar changes.
type RoomMetaEventContent ¶
type RoomMetaEventContent interface { *event.RoomNameEventContent | *event.RoomAvatarEventContent | *event.TopicEventContent }
type RoomNameHandlingNetworkAPI ¶
type RoomNameHandlingNetworkAPI interface { NetworkAPI // HandleMatrixRoomName is called when the name of a portal room is changed. // This method should update the Name and NameSet fields of the Portal with // the new name and return true if the change was successful. // If the change is not successful, then the fields should not be updated. HandleMatrixRoomName(ctx context.Context, msg *MatrixRoomName) (bool, error) }
RoomNameHandlingNetworkAPI is an optional interface that network connectors can implement to handle room name changes.
type RoomTopicHandlingNetworkAPI ¶
type RoomTopicHandlingNetworkAPI interface { NetworkAPI // HandleMatrixRoomTopic is called when the topic of a portal room is changed. // This method should update the Topic and TopicSet fields of the Portal with // the new topic and return true if the change was successful. // If the change is not successful, then the fields should not be updated. HandleMatrixRoomTopic(ctx context.Context, msg *MatrixRoomTopic) (bool, error) }
RoomTopicHandlingNetworkAPI is an optional interface that network connectors can implement to handle room topic changes.
type SimpleRemoteEvent ¶
type SimpleRemoteEvent[T any] struct { Type RemoteEventType LogContext func(c zerolog.Context) zerolog.Context PortalKey networkid.PortalKey Data T CreatePortal bool ID networkid.MessageID Sender EventSender TargetMessage networkid.MessageID EmojiID networkid.EmojiID Emoji string ReactionDBMeta any Timestamp time.Time ChatInfoChange *ChatInfoChange ConvertMessageFunc func(ctx context.Context, portal *Portal, intent MatrixAPI, data T) (*ConvertedMessage, error) ConvertEditFunc func(ctx context.Context, portal *Portal, intent MatrixAPI, existing []*database.Message, data T) (*ConvertedEdit, error) }
SimpleRemoteEvent is a simple implementation of RemoteEvent that can be used with struct fields and some callbacks.
func (*SimpleRemoteEvent[T]) AddLogContext ¶
func (sre *SimpleRemoteEvent[T]) AddLogContext(c zerolog.Context) zerolog.Context
func (*SimpleRemoteEvent[T]) ConvertEdit ¶
func (sre *SimpleRemoteEvent[T]) ConvertEdit(ctx context.Context, portal *Portal, intent MatrixAPI, existing []*database.Message) (*ConvertedEdit, error)
func (*SimpleRemoteEvent[T]) ConvertMessage ¶
func (sre *SimpleRemoteEvent[T]) ConvertMessage(ctx context.Context, portal *Portal, intent MatrixAPI) (*ConvertedMessage, error)
func (*SimpleRemoteEvent[T]) GetChatInfoChange ¶
func (sre *SimpleRemoteEvent[T]) GetChatInfoChange(ctx context.Context) (*ChatInfoChange, error)
func (*SimpleRemoteEvent[T]) GetID ¶
func (sre *SimpleRemoteEvent[T]) GetID() networkid.MessageID
func (*SimpleRemoteEvent[T]) GetPortalKey ¶
func (sre *SimpleRemoteEvent[T]) GetPortalKey() networkid.PortalKey
func (*SimpleRemoteEvent[T]) GetReactionDBMetadata ¶
func (sre *SimpleRemoteEvent[T]) GetReactionDBMetadata() any
func (*SimpleRemoteEvent[T]) GetReactionEmoji ¶
func (sre *SimpleRemoteEvent[T]) GetReactionEmoji() (string, networkid.EmojiID)
func (*SimpleRemoteEvent[T]) GetRemovedEmojiID ¶
func (sre *SimpleRemoteEvent[T]) GetRemovedEmojiID() networkid.EmojiID
func (*SimpleRemoteEvent[T]) GetSender ¶
func (sre *SimpleRemoteEvent[T]) GetSender() EventSender
func (*SimpleRemoteEvent[T]) GetTargetMessage ¶
func (sre *SimpleRemoteEvent[T]) GetTargetMessage() networkid.MessageID
func (*SimpleRemoteEvent[T]) GetTimestamp ¶
func (sre *SimpleRemoteEvent[T]) GetTimestamp() time.Time
func (*SimpleRemoteEvent[T]) GetType ¶
func (sre *SimpleRemoteEvent[T]) GetType() RemoteEventType
func (*SimpleRemoteEvent[T]) ShouldCreatePortal ¶
func (sre *SimpleRemoteEvent[T]) ShouldCreatePortal() bool
type TypingHandlingNetworkAPI ¶
type TypingHandlingNetworkAPI interface { NetworkAPI // HandleMatrixTyping is called when a user starts typing in a portal room. // In the future, the central bridge module will likely get a loop to automatically repeat // calls to this function until the user stops typing. HandleMatrixTyping(ctx context.Context, msg *MatrixTyping) error }
TypingHandlingNetworkAPI is an optional interface that network connectors can implement to handle typing events.
type TypingType ¶
type TypingType int
const ( TypingTypeText TypingType = iota TypingTypeUploadingMedia TypingTypeRecordingMedia )
type User ¶
type User struct { *database.User Bridge *Bridge Log zerolog.Logger CommandState unsafe.Pointer Permissions bridgeconfig.Permissions // contains filtered or unexported fields }
func (*User) GetCachedUserLogins ¶
func (*User) GetDefaultLogin ¶
func (*User) GetFormattedUserLogins ¶
func (*User) GetManagementRoom ¶
func (*User) GetUserLoginIDs ¶
func (user *User) GetUserLoginIDs() []networkid.UserLoginID
func (*User) LoginDoublePuppet ¶
func (*User) LogoutDoublePuppet ¶
func (*User) NewLogin ¶
func (user *User) NewLogin(ctx context.Context, data *database.UserLogin, params *NewLoginParams) (*UserLogin, error)
NewLogin creates a UserLogin object for this user with the given parameters.
If a login already exists with the same ID, it is reused after updating the remote name and metadata from the provided data, unless DontReuseExisting is set in params.
If the existing login belongs to another user, this returns an error, unless DeleteOnConflict is set in the params, in which case the existing login is deleted.
This will automatically call LoadUserLogin after creating the UserLogin object. The load method defaults to the network connector's LoadUserLogin method, but it can be overridden in params.
type UserLocalPortalInfo ¶
type UserLogin ¶
type UserLogin struct { *database.UserLogin Bridge *Bridge User *User Log zerolog.Logger Client NetworkAPI BridgeState *BridgeStateQueue // contains filtered or unexported fields }
func (*UserLogin) AddPortalToSpace ¶
func (*UserLogin) Disconnect ¶
func (ul *UserLogin) Disconnect(done func())
func (*UserLogin) GetRemoteID ¶
func (*UserLogin) GetRemoteName ¶
func (*UserLogin) GetSpaceRoom ¶
func (*UserLogin) MarkAsPreferredIn ¶
func (*UserLogin) MarkInPortal ¶
type UserSearchingNetworkAPI ¶
type UserSearchingNetworkAPI interface { IdentifierResolvingNetworkAPI SearchUsers(ctx context.Context, query string) ([]*ResolveIdentifierResponse, error) }
type WebPushConfig ¶
type WebPushConfig struct {
VapidKey string `json:"vapid_key"`
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
mxmain
Package mxmain contains initialization code for a single-network Matrix bridge using the bridgev2 package.
|
Package mxmain contains initialization code for a single-network Matrix bridge using the bridgev2 package. |
Package networkid contains string types used to represent different kinds of identifiers on remote networks.
|
Package networkid contains string types used to represent different kinds of identifiers on remote networks. |