refactor(builder): move messenger, instagram and whatsapp data access into business - #1100
Open
realcodesiman wants to merge 1 commit into
Open
refactor(builder): move messenger, instagram and whatsapp data access into business#1100realcodesiman wants to merge 1 commit into
realcodesiman wants to merge 1 commit into
Conversation
… into business Removes direct db usage from the Meta channel integrations (Messenger, Instagram, WhatsApp) and the shared OAuth callback per .agents/rules/data-access.md. - messenger/instagram: connectMessengerPage / connectInstagramAccount hold the connect transaction; deleteWithCleanup keeps the teardown -> tag-channel -> capi -> integration -> inbox order in one transaction; updateSettings, listForWorkspace, syncMessageTemplates and the message-template repository reads/deletes - whatsapp: connectPhoneNumber (signup session consumed in the same transaction, unique violation mapped to a typed exception), deleteWithCleanup, markWebhookVerified/OverrideOk, client-safe list columns moved into the repository, flow/template sync repositories - integrationService.createFromOAuthCallback for the callback route Meta API calls that used to run inside the connect/update transactions now run outside them (business does not depend on the channel SDKs); the Instagram native-login webhook subscribe runs before the DB write so a failed subscribe still prevents the connect, matching the Messenger action. Pinned by instagram-select-account-ordering.test.ts.
5 tasks
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.
Summary
db.*call from the Meta channel integrations in the builder (Messenger, Instagram, WhatsApp: connect, disconnect, update, queries, template/flow sync) and the shared OAuth callback, per.agents/rules/data-access.md.main, one-line barrel append only (./whatsapp-message-template, also added by the automation PR; keep one).Changes
connectMessengerPage/connectInstagramAccounthold the connect transaction (DB work only);deleteWithCleanupkeeps the teardown → tag-channel → CAPI → integration → inbox order in one transaction;updateSettings,listForWorkspace,syncMessageTemplates; message-template reads/deletes onintegrationMessengerRepository.connectPhoneNumber(signup session consumed in the same transaction, unique violation → typedChatbotXExceptionthe action maps to its translated strings),deleteWithCleanup(reusescoexistService.tearDownForIntegration, which adds achannelfilter; safe becauseintegrationIdis unique),markWebhookVerified/markWebhookOverrideOk, the client-safe column allowlist moved intointegrationWhatsappRepository.listClientSafeByWorkspaceId(pinned by a test thatauth/capiAccessTokenstay excluded),whatsappFlowRepository.syncForIntegrationand a newwhatsapp-message-templaterepository.integrationService.createFromOAuthCallbackforapp/integrations/[...integration]/callback.ts.Behavior changes
update-messenger-action,update-instagram-actionand both Instagram select-account actions (business does not depend on the channel SDKs). Guards run before the write. The Instagram native-login webhook subscribe now runs before the DB write, so a failed subscribe still prevents the connect without leaving an orphaned row, matching the Messenger select-page action. Pinned byapps/builder/__tests__/instagram-select-account-ordering.test.ts.deleteWithCleanupfor Messenger/Instagram lives in sibling files (integration-{messenger,instagram}/disconnect.ts) to keep the existing service test's import graph intact.Test plan
pnpm --filter @chatbotx.io/database check-types && testpnpm --filter @chatbotx.io/business check-types && test(only the pre-existingads-conversion-rule.service.test.tsfailures remain, also red onmain)pnpm --filter builder check-types && testpnpm lint