This commit is contained in:
debu-2 2026-10-14 05:46:18 +05:30
parent dcae960928
commit a7e6ed2e4b
3 changed files with 107 additions and 14 deletions

View file

@ -112,11 +112,16 @@ function parseSignupMessage(raw: unknown): SignupSession | null {
const message = data as { type?: string; event?: string; data?: Record<string, unknown> }
if (message.type !== 'WA_EMBEDDED_SIGNUP' || !message.event) return null
const body = message.data || {}
const metaId = (value: unknown) => {
if (typeof value === 'string' && value.trim()) return value.trim()
if (typeof value === 'number' && Number.isFinite(value)) return String(Math.trunc(value))
return undefined
}
return {
event: message.event,
wabaId: typeof body.waba_id === 'string' ? body.waba_id : undefined,
phoneNumberId: typeof body.phone_number_id === 'string' ? body.phone_number_id : undefined,
businessId: typeof body.business_id === 'string' ? body.business_id : undefined,
wabaId: metaId(body.waba_id),
phoneNumberId: metaId(body.phone_number_id),
businessId: metaId(body.business_id),
errorMessage: typeof body.error_message === 'string' ? body.error_message : undefined,
currentStep: typeof body.current_step === 'string' ? body.current_step : undefined,
}
@ -311,7 +316,7 @@ export function WhatsAppSetupPage() {
config_id: config.config_id,
response_type: 'code',
override_default_response_type: true,
extras: {},
extras: { sessionInfoVersion: 3 },
},
)
} catch (reason) {