feat(whatsapp): mensajes automáticos semanales con proveedor intercambiable

- Puerto MessagingProvider con adaptadores OpenWA (MVP, QR) y Kapso
  (setup link de Meta + templates), elegido con WHATSAPP_PROVIDER.
- Vinculación del WhatsApp del profesor en el onboarding y en Ajustes.
- Job semanal (lunes 10:00 AR): recordatorio de pago y reenganche a
  alumnos en riesgo (cooldown 14 días), con switches por grupo.
- Idempotencia por (kind, attendee, semana ISO), webhooks firmados con
  HMAC y deduplicados, normalización de teléfonos a E.164.
- Servicio openwa en docker-compose y guía en docs/whatsapp.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-22 08:38:09 -03:00
parent 8c5caecdda
commit ec65c2198d
90 changed files with 6784 additions and 117 deletions

View File

@@ -9,6 +9,9 @@ const db = {
mpAccount: {
findUnique: mock(),
},
whatsappAccount: {
findUnique: mock(async () => null),
},
group: {
create: mock(),
},
@@ -54,6 +57,8 @@ const group = {
price: 150.5,
billingType: 'MONTHLY',
dueDay: 5,
autoPaymentReminders: false,
autoReengagement: false,
};
const firstGroupPayload = {
@@ -83,6 +88,7 @@ describe('onboarding routes', () => {
expect(await res.json()).toEqual({
step: 'NOT_STARTED',
paymentConnected: false,
whatsappConnected: false,
completed: false,
});
});
@@ -97,6 +103,7 @@ describe('onboarding routes', () => {
expect(await res.json()).toEqual({
step: 'PAYMENT_CONNECTED',
paymentConnected: true,
whatsappConnected: false,
completed: false,
});
});
@@ -115,6 +122,7 @@ describe('onboarding routes', () => {
expect(await res.json()).toEqual({
step: 'NOT_STARTED',
paymentConnected: false,
whatsappConnected: false,
completed: false,
});
});
@@ -128,6 +136,7 @@ describe('onboarding routes', () => {
expect(await res.json()).toEqual({
step: 'COMPLETED',
paymentConnected: true,
whatsappConnected: false,
completed: true,
});
});
@@ -166,6 +175,8 @@ describe('onboarding routes', () => {
price: 150.5,
billingType: 'MONTHLY',
dueDay: 5,
autoPaymentReminders: false,
autoReengagement: false,
},
onboardingCompleted: true,
});