import { defineLogicFunction } from "twenty-sdk/define"; import { getConnection } from "twenty-sdk/logic-function"; import { SAJN_CONNECTION_PROVIDER_NAME, SAJN_ON_CONNECT_UNIVERSAL_IDENTIFIER, } from "src/constants/universal-identifiers"; import { configureSajnWebhook } from "src/logic-functions/utils/sajn-webhook-registration"; type OnConnectPayload = { connectionProviderId: string; connectionProviderName: string; connectedAccountId: string; }; const handler = async (payload: OnConnectPayload): Promise => { if (payload.connectionProviderName !== SAJN_CONNECTION_PROVIDER_NAME) { return; } const connection = await getConnection(payload.connectedAccountId); await configureSajnWebhook(connection); }; export default defineLogicFunction({ universalIdentifier: SAJN_ON_CONNECT_UNIVERSAL_IDENTIFIER, name: "configure-sajn-after-connect", description: "Creates the sajn status webhook after OAuth connection.", timeoutSeconds: 30, handler, });