feat(whatsapp): vincular con el número de teléfono además del QR

Desde el teléfono no se puede escanear el QR de la propia pantalla. Con
OpenWA el profesor ahora puede escribir su número y recibir un código de
8 caracteres para ingresar en WhatsApp (POST /whatsapp/connect/pairing-code).
En mobile el modal arranca por el número y en desktop por el QR.

- Puerto: requestPairingCode opcional (Kapso no lo implementa).
- OpenWA: reintenta el 409 mientras la sesión arranca.
- Número normalizado con el país del profesor (toWhatsappE164).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-22 19:15:02 -03:00
parent bef4056f8e
commit f4d2c26e29
23 changed files with 619 additions and 82 deletions

View File

@@ -49,6 +49,22 @@ export const WhatsappConnectResultDtoSchema = z.object({
});
export type WhatsappConnectResultDto = z.output<typeof WhatsappConnectResultDtoSchema>;
// Linking by phone number instead of QR (OpenWA): the teacher types their own
// number and enters the code WhatsApp asks for on that phone. It is the only
// way to link from the same phone the app is running on, where a QR cannot be
// scanned. National or international format; the server normalizes it with the
// teacher's country.
export const WhatsappPairingCodeSchema = z.strictObject({
phoneNumber: z.string().trim().min(6, 'Ingresá tu número de WhatsApp').max(30),
});
export type WhatsappPairingCode = z.output<typeof WhatsappPairingCodeSchema>;
export const WhatsappPairingCodeDtoSchema = z.object({
// 8 characters, as WhatsApp shows them (e.g. `ABCD1234`).
pairingCode: z.string(),
});
export type WhatsappPairingCodeDto = z.output<typeof WhatsappPairingCodeDtoSchema>;
export const WhatsappStatusDtoSchema = z.object({
status: whatsappAccountStatusSchema,
provider: whatsappProviderSchema,