Add Facebook Page login via Business Suite - #313
Open
aminebalti55 wants to merge 1 commit into
Open
Conversation
Adds a login mode that authenticates against business.facebook.com and bridges a managed Facebook Page's inbox, instead of or alongside a personal Messenger account. Pages still receive messages over Meta's MQTT-over-websocket transport rather than the newer DGW/lightspeed socket used for personal accounts, so a dedicated Business Suite MQTT client is added to handle that transport, discover the Pages available to a logged-in account, and correctly separate the mixed Facebook/Instagram threads returned by the unified Business Inbox sync stream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Today the bridge can only log in as a personal Facebook or Messenger account. Businesses that manage their customer conversations through a Facebook Page have no way to bridge that Page's inbox — only a personal profile's DMs are supported.
Facebook Pages are also a materially different product surface: Page messaging is managed through business.facebook.com ("Business Suite"), and Pages still receive messages over an older real-time transport than the one personal accounts now use. Supporting Pages isn't just a new login screen — it requires a different way of receiving live messages and different handling of how threads are organized.
Solution
This PR adds Business Suite as a login option. A user can authenticate against business.facebook.com, select which Facebook Page they manage, and bridge that Page's inbox into Matrix — separately from, or alongside, a personal Messenger login.
To make that work end-to-end:
The result is that anyone managing a Facebook Page can bridge its customer conversations the same way personal Messenger accounts are bridged today.
Testing
go build,go vet, andgo testpass across all changed packages.Technical details
pkg/connector/login.go,pkg/messagix/types/client.go): adds aBusinessSuiteplatform value alongside the existing Facebook/Messenger/MessengerLite modes. Login authenticates againstbusiness.facebook.com, discovers the account's manageable Pages via a GraphQL query, and lets the user pick one. Page identity (business ID, asset ID, page ID) is stored in login metadata so portals and future reconnects stay scoped to the correct Page.pkg/messagix/businesssuite_socket.go): Facebook Pages still deliver Lightspeed traffic over Meta's MQTT-3.1-over-websocket protocol, while personal accounts have moved to a newer DGW-based socket. This adds a minimal, purpose-built MQTT client (connect/subscribe/publish/ack handling, with bounds-checked frame parsing) kept isolated from the existing DGW socket so Page-specific behavior can't leak into the personal-account code path. The broker endpoint is read from the account's live config, so as a defense-in-depth measure, the dial target is validated to be awss://connection to a Meta-owned host before the session's cookies are attached.pkg/connector/businesssuite_filter.go,pkg/connector/ids.go): the unified Business Inbox snapshot returns Facebook and Instagram threads in the same sync group, distinguished only by a secondary marker. This tracks which threads are actually Instagram-sourced so they're routed correctly instead of being treated as Facebook Page messages.pkg/messagix/socket.go,pkg/messagix/syncManager.go): Business Suite requires syncing a different set of database groups than personal accounts, and its request/response flow goes through the new MQTT client rather than the DGW stream, so sync selection and response handling account for both transports.