connector

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2024 License: AGPL-3.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WADisconnected             status.BridgeStateErrorCode = "wa-transient-disconnect"
	WAPermanentError           status.BridgeStateErrorCode = "wa-unknown-permanent-error"
	WACATError                 status.BridgeStateErrorCode = "wa-cat-refresh-error"
	MetaConnectionUnauthorized status.BridgeStateErrorCode = "meta-connection-unauthorized"
	MetaPermanentError         status.BridgeStateErrorCode = "meta-unknown-permanent-error"
	MetaCookieRemoved          status.BridgeStateErrorCode = "meta-cookie-removed"
	MetaNotLoggedIn            status.BridgeStateErrorCode = "meta-not-logged-in"
	MetaConnectError           status.BridgeStateErrorCode = "meta-connect-error"
	MetaTransientDisconnect    status.BridgeStateErrorCode = "meta-transient-disconnect"
	IGChallengeRequired        status.BridgeStateErrorCode = "ig-challenge-required"
	IGChallengeRequiredMaybe   status.BridgeStateErrorCode = "ig-challenge-required-maybe"
	IGAccountSuspended         status.BridgeStateErrorCode = "ig-account-suspended"
	MetaServerUnavailable      status.BridgeStateErrorCode = "meta-server-unavailable"
	IGConsentRequired          status.BridgeStateErrorCode = "ig-consent-required"
	FBConsentRequired          status.BridgeStateErrorCode = "fb-consent-required"
)
View Source
const (
	FlowIDFacebookCookies  = "cookies-facebook"
	FlowIDMessengerCookies = "cookies-messenger"
	FlowIDInstagramCookies = "cookies-instagram"

	LoginStepIDCookies  = "fi.mau.meta.cookies"
	LoginStepIDComplete = "fi.mau.meta.complete"
)
View Source
const ConnectWaitTimeout = 1 * time.Minute

Variables

View Source
var (
	ErrServerRejectedMessage = bridgev2.WrapErrorInStatus(errors.New("server rejected message")).WithErrorAsMessage().WithSendNotice(true)
	ErrNotConnected          = bridgev2.WrapErrorInStatus(errors.New("not connected")).WithErrorAsMessage().WithSendNotice(true)
)
View Source
var (
	ErrLoginMissingCookies   = bridgev2.RespError{ErrCode: "FI.MAU.META_MISSING_COOKIES", Err: "Missing cookies", StatusCode: http.StatusBadRequest}
	ErrLoginChallenge        = bridgev2.RespError{ErrCode: "FI.MAU.META_CHALLENGE_ERROR", Err: "Challenge required, please check the official website or app and then try again", StatusCode: http.StatusBadRequest}
	ErrLoginConsent          = bridgev2.RespError{ErrCode: "FI.MAU.META_CONSENT_ERROR", Err: "Consent required, please check the official website or app and then try again", StatusCode: http.StatusBadRequest}
	ErrLoginTokenInvalidated = bridgev2.RespError{ErrCode: "FI.MAU.META_TOKEN_ERROR", Err: "Got logged out immediately", StatusCode: http.StatusBadRequest}
	ErrLoginUnknown          = bridgev2.RespError{ErrCode: "M_UNKNOWN", Err: "Internal error logging in", StatusCode: http.StatusInternalServerError}
)
View Source
var ExampleConfig string

Functions

This section is empty.

Types

type BackfillCollector

type BackfillCollector struct {
	*table.UpsertMessages
	MaxMessages int
	Forward     bool
	Anchor      *database.Message
	Done        func()
}

type Config

type Config struct {
	RawMode string         `yaml:"mode"`
	Mode    types.Platform `yaml:"-"`
	IGE2EE  bool           `yaml:"ig_e2ee"`

	Proxy        string `yaml:"proxy"`
	GetProxyFrom string `yaml:"get_proxy_from"`

	DisableXMABackfill bool `yaml:"disable_xma_backfill"`
	DisableXMAAlways   bool `yaml:"disable_xma_always"`

	MinFullReconnectIntervalSeconds int `yaml:"min_full_reconnect_interval_seconds"`
	ForceRefreshIntervalSeconds     int `yaml:"force_refresh_interval_seconds"`

	DisplaynameTemplate string `yaml:"displayname_template"`
	// contains filtered or unexported fields
}

func (*Config) FormatDisplayname

func (c *Config) FormatDisplayname(params DisplaynameParams) string

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(node *yaml.Node) error

type DisplaynameParams

type DisplaynameParams struct {
	DisplayName string
	Username    string
	ID          int64
}

type EnsureWAChatStateEvent

type EnsureWAChatStateEvent struct {
	JID types.JID
	// contains filtered or unexported fields
}

func (*EnsureWAChatStateEvent) AddLogContext

func (evt *EnsureWAChatStateEvent) AddLogContext(c zerolog.Context) zerolog.Context

func (*EnsureWAChatStateEvent) GetChatInfo

func (evt *EnsureWAChatStateEvent) GetChatInfo(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error)

func (*EnsureWAChatStateEvent) GetPortalKey

func (evt *EnsureWAChatStateEvent) GetPortalKey() networkid.PortalKey

func (*EnsureWAChatStateEvent) GetSender

func (evt *EnsureWAChatStateEvent) GetSender() bridgev2.EventSender

func (*EnsureWAChatStateEvent) GetType

func (*EnsureWAChatStateEvent) ShouldCreatePortal

func (evt *EnsureWAChatStateEvent) ShouldCreatePortal() bool

type FBChatResync

type FBChatResync struct {
	Raw       *table.LSDeleteThenInsertThread
	PortalKey networkid.PortalKey
	Info      *bridgev2.ChatInfo
	Members   map[int64]bridgev2.ChatMember
	Backfill  *table.UpsertMessages
	UpsertID  int64
	// contains filtered or unexported fields
}

func (*FBChatResync) AddLogContext

func (r *FBChatResync) AddLogContext(c zerolog.Context) zerolog.Context

func (*FBChatResync) CheckNeedsBackfill

func (r *FBChatResync) CheckNeedsBackfill(ctx context.Context, lastMessage *database.Message) (bool, error)

func (*FBChatResync) GetBundledBackfillData

func (r *FBChatResync) GetBundledBackfillData() any

func (*FBChatResync) GetChatInfo

func (r *FBChatResync) GetChatInfo(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error)

func (*FBChatResync) GetPortalKey

func (r *FBChatResync) GetPortalKey() networkid.PortalKey

func (*FBChatResync) GetSender

func (r *FBChatResync) GetSender() bridgev2.EventSender

func (*FBChatResync) GetType

func (r *FBChatResync) GetType() bridgev2.RemoteEventType

func (*FBChatResync) ShouldCreatePortal

func (r *FBChatResync) ShouldCreatePortal() bool

type FBEditEvent

type FBEditEvent struct {
	*table.LSEditMessage
	// contains filtered or unexported fields
}

func (*FBEditEvent) AddLogContext

func (evt *FBEditEvent) AddLogContext(c zerolog.Context) zerolog.Context

func (*FBEditEvent) ConvertEdit

func (evt *FBEditEvent) ConvertEdit(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, existing []*database.Message) (*bridgev2.ConvertedEdit, error)

func (*FBEditEvent) GetPortalKey

func (evt *FBEditEvent) GetPortalKey() networkid.PortalKey

func (*FBEditEvent) GetSender

func (evt *FBEditEvent) GetSender() bridgev2.EventSender

func (*FBEditEvent) GetTargetMessage

func (evt *FBEditEvent) GetTargetMessage() networkid.MessageID

func (*FBEditEvent) GetType

func (evt *FBEditEvent) GetType() bridgev2.RemoteEventType

type FBMessageEvent

type FBMessageEvent struct {
	*table.WrappedMessage
	// contains filtered or unexported fields
}

func (*FBMessageEvent) AddLogContext

func (evt *FBMessageEvent) AddLogContext(c zerolog.Context) zerolog.Context

func (*FBMessageEvent) ConvertMessage

func (evt *FBMessageEvent) ConvertMessage(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI) (*bridgev2.ConvertedMessage, error)

func (*FBMessageEvent) GetID

func (evt *FBMessageEvent) GetID() networkid.MessageID

func (*FBMessageEvent) GetPortalKey

func (evt *FBMessageEvent) GetPortalKey() networkid.PortalKey

func (*FBMessageEvent) GetSender

func (evt *FBMessageEvent) GetSender() bridgev2.EventSender

func (*FBMessageEvent) GetTimestamp

func (evt *FBMessageEvent) GetTimestamp() time.Time

func (*FBMessageEvent) GetType

func (evt *FBMessageEvent) GetType() bridgev2.RemoteEventType

func (*FBMessageEvent) PortalReceiverIsUncertain

func (evt *FBMessageEvent) PortalReceiverIsUncertain() bool

type MetaClient

type MetaClient struct {
	Main      *MetaConnector
	Client    *messagix.Client
	LoginMeta *metaid.UserLoginMetadata
	UserLogin *bridgev2.UserLogin
	Ghost     *bridgev2.Ghost

	E2EEClient *whatsmeow.Client
	WADevice   *store.Device
	// contains filtered or unexported fields
}

func (*MetaClient) Connect

func (m *MetaClient) Connect(ctx context.Context) error

func (*MetaClient) Disconnect

func (m *MetaClient) Disconnect()

func (*MetaClient) FetchMessages

func (*MetaClient) FillBridgeState

func (m *MetaClient) FillBridgeState(state status.BridgeState) status.BridgeState

func (*MetaClient) FullReconnect

func (m *MetaClient) FullReconnect()

func (*MetaClient) GetCapabilities

func (m *MetaClient) GetCapabilities(ctx context.Context, portal *bridgev2.Portal) *bridgev2.NetworkRoomCapabilities

func (*MetaClient) GetChatInfo

func (m *MetaClient) GetChatInfo(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error)

func (*MetaClient) GetUserInfo

func (m *MetaClient) GetUserInfo(ctx context.Context, ghost *bridgev2.Ghost) (*bridgev2.UserInfo, error)

func (*MetaClient) HandleMatrixEdit

func (m *MetaClient) HandleMatrixEdit(ctx context.Context, edit *bridgev2.MatrixEdit) error

func (*MetaClient) HandleMatrixMessage

func (m *MetaClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.MatrixMessage) (*bridgev2.MatrixMessageResponse, error)

func (*MetaClient) HandleMatrixMessageRemove

func (m *MetaClient) HandleMatrixMessageRemove(ctx context.Context, msg *bridgev2.MatrixMessageRemove) error

func (*MetaClient) HandleMatrixReaction

func (m *MetaClient) HandleMatrixReaction(ctx context.Context, msg *bridgev2.MatrixReaction) (*database.Reaction, error)

func (*MetaClient) HandleMatrixReactionRemove

func (m *MetaClient) HandleMatrixReactionRemove(ctx context.Context, msg *bridgev2.MatrixReactionRemove) error

func (*MetaClient) HandleMatrixReadReceipt

func (m *MetaClient) HandleMatrixReadReceipt(ctx context.Context, receipt *bridgev2.MatrixReadReceipt) error

func (*MetaClient) IsLoggedIn

func (m *MetaClient) IsLoggedIn() bool

func (*MetaClient) IsThisUser

func (m *MetaClient) IsThisUser(ctx context.Context, userID networkid.UserID) bool

func (*MetaClient) LogoutRemote

func (m *MetaClient) LogoutRemote(ctx context.Context)

func (*MetaClient) PreHandleMatrixReaction

func (m *MetaClient) PreHandleMatrixReaction(ctx context.Context, msg *bridgev2.MatrixReaction) (bridgev2.MatrixReactionPreResponse, error)

func (*MetaClient) ResolveIdentifier

func (m *MetaClient) ResolveIdentifier(ctx context.Context, identifier string, createChat bool) (*bridgev2.ResolveIdentifierResponse, error)

func (*MetaClient) SearchUsers

func (m *MetaClient) SearchUsers(ctx context.Context, search string) ([]*bridgev2.ResolveIdentifierResponse, error)

type MetaConnector

type MetaConnector struct {
	Bridge      *bridgev2.Bridge
	Config      Config
	MsgConv     *msgconv.MessageConverter
	DeviceStore *sqlstore.Container
	DB          *metadb.MetaDB
}

func (*MetaConnector) CreateLogin

func (m *MetaConnector) CreateLogin(ctx context.Context, user *bridgev2.User, flowID string) (bridgev2.LoginProcess, error)

func (*MetaConnector) GetCapabilities

func (m *MetaConnector) GetCapabilities() *bridgev2.NetworkGeneralCapabilities

func (*MetaConnector) GetConfig

func (m *MetaConnector) GetConfig() (string, any, up.Upgrader)

func (*MetaConnector) GetDBMetaTypes

func (m *MetaConnector) GetDBMetaTypes() database.MetaTypes

func (*MetaConnector) GetLoginFlows

func (m *MetaConnector) GetLoginFlows() []bridgev2.LoginFlow

func (*MetaConnector) GetName

func (m *MetaConnector) GetName() bridgev2.BridgeName

func (*MetaConnector) Init

func (m *MetaConnector) Init(bridge *bridgev2.Bridge)

func (*MetaConnector) LoadUserLogin

func (m *MetaConnector) LoadUserLogin(ctx context.Context, login *bridgev2.UserLogin) error

func (*MetaConnector) SetMaxFileSize

func (m *MetaConnector) SetMaxFileSize(maxSize int64)

func (*MetaConnector) Start

func (m *MetaConnector) Start(ctx context.Context) error

func (*MetaConnector) ValidateConfig

func (m *MetaConnector) ValidateConfig() error

func (*MetaConnector) ValidateUserID

func (m *MetaConnector) ValidateUserID(id networkid.UserID) bool

type MetaCookieLogin

type MetaCookieLogin struct {
	Mode types.Platform
	User *bridgev2.User
	Main *MetaConnector
}

func (*MetaCookieLogin) Cancel

func (m *MetaCookieLogin) Cancel()

func (*MetaCookieLogin) Start

func (*MetaCookieLogin) SubmitCookies

func (m *MetaCookieLogin) SubmitCookies(ctx context.Context, strCookies map[string]string) (*bridgev2.LoginStep, error)

type ThreadKeyable

type ThreadKeyable interface {
	GetThreadKey() int64
}

type VerifyThreadExistsEvent

type VerifyThreadExistsEvent struct {
	*table.LSVerifyThreadExists
	// contains filtered or unexported fields
}

func (*VerifyThreadExistsEvent) AddLogContext

func (evt *VerifyThreadExistsEvent) AddLogContext(c zerolog.Context) zerolog.Context

func (*VerifyThreadExistsEvent) GetChatInfo

func (evt *VerifyThreadExistsEvent) GetChatInfo(ctx context.Context, portal *bridgev2.Portal) (*bridgev2.ChatInfo, error)

func (*VerifyThreadExistsEvent) GetPortalKey

func (evt *VerifyThreadExistsEvent) GetPortalKey() networkid.PortalKey

func (*VerifyThreadExistsEvent) GetSender

func (evt *VerifyThreadExistsEvent) GetSender() bridgev2.EventSender

func (*VerifyThreadExistsEvent) GetType

func (*VerifyThreadExistsEvent) ShouldCreatePortal

func (evt *VerifyThreadExistsEvent) ShouldCreatePortal() bool

type WAMessageEvent

type WAMessageEvent struct {
	*events.FBMessage
	// contains filtered or unexported fields
}

func (*WAMessageEvent) AddLogContext

func (evt *WAMessageEvent) AddLogContext(c zerolog.Context) zerolog.Context

func (*WAMessageEvent) ConvertEdit

func (evt *WAMessageEvent) ConvertEdit(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, existing []*database.Message) (*bridgev2.ConvertedEdit, error)

func (*WAMessageEvent) ConvertMessage

func (evt *WAMessageEvent) ConvertMessage(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI) (*bridgev2.ConvertedMessage, error)

func (*WAMessageEvent) GetID

func (evt *WAMessageEvent) GetID() networkid.MessageID

func (*WAMessageEvent) GetPortalKey

func (evt *WAMessageEvent) GetPortalKey() networkid.PortalKey

func (*WAMessageEvent) GetReactionEmoji

func (evt *WAMessageEvent) GetReactionEmoji() (string, networkid.EmojiID)

func (*WAMessageEvent) GetRemovedEmojiID

func (evt *WAMessageEvent) GetRemovedEmojiID() networkid.EmojiID

func (*WAMessageEvent) GetSender

func (evt *WAMessageEvent) GetSender() bridgev2.EventSender

func (*WAMessageEvent) GetTargetMessage

func (evt *WAMessageEvent) GetTargetMessage() networkid.MessageID

func (*WAMessageEvent) GetTimestamp

func (evt *WAMessageEvent) GetTimestamp() time.Time

func (*WAMessageEvent) GetType

func (evt *WAMessageEvent) GetType() bridgev2.RemoteEventType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL