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:
@@ -50,6 +50,17 @@ describe('session auth', () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('classifies the WhatsApp provider webhooks as public (signature-based)', () => {
|
||||
expect(isPublicApiRequest('POST', '/api/v1/whatsapp/webhooks/openwa')).toBe(true);
|
||||
expect(isPublicApiRequest('POST', '/api/v1/whatsapp/webhooks/kapso/')).toBe(true);
|
||||
// Everything else under /whatsapp needs the teacher's session.
|
||||
expect(isPublicApiRequest('GET', '/api/v1/whatsapp/webhooks/openwa')).toBe(false);
|
||||
expect(isPublicApiRequest('POST', '/api/v1/whatsapp/webhooks/other')).toBe(false);
|
||||
expect(isPublicApiRequest('GET', '/api/v1/whatsapp/status')).toBe(false);
|
||||
expect(isPublicApiRequest('POST', '/api/v1/whatsapp/connect')).toBe(false);
|
||||
expect(isPublicApiRequest('GET', '/api/v1/whatsapp/callback')).toBe(false);
|
||||
});
|
||||
|
||||
it('allows public requests without a session', async () => {
|
||||
const app = new Hono();
|
||||
app.use('*', sessionAuthMiddleware);
|
||||
|
||||
Reference in New Issue
Block a user