feat: agregar soporte para plantillas de WhatsApp en el controlador de notificaciones, incluyendo nuevos parámetros y un endpoint de prueba

This commit is contained in:
2026-09-19 12:30:52 -03:00
parent 40bc65396f
commit ee67ac538e
4 changed files with 62 additions and 29 deletions
@@ -20,6 +20,9 @@ export interface NotificationJobPayload {
wapMessage?: string; wapMessage?: string;
systemSubject?: string; systemSubject?: string;
systemMessage?: string; systemMessage?: string;
templateName?: string;
languageCode?: string;
templateVariables?: string[];
} }
export interface INotificationJob { export interface INotificationJob {
@@ -28,6 +28,9 @@ export interface NotificationJobPayload {
wapMessage?: string; wapMessage?: string;
systemSubject?: string; systemSubject?: string;
systemMessage?: string; systemMessage?: string;
templateName?: string;
languageCode?: string;
templateVariables?: string[];
} }
export interface INotificationJob { export interface INotificationJob {
@@ -5,7 +5,7 @@ export class NotificationsMetaAdapter implements INotificationsAdapter<Notificat
// ── Datos hardcodeados para pruebas (etapa 1) ── // ── Datos hardcodeados para pruebas (etapa 1) ──
private readonly phoneNumberId = "1379557278565544"; // ej: "1379557278565544" private readonly phoneNumberId = "1379557278565544"; // ej: "1379557278565544"
private readonly authToken = private readonly authToken =
"EAAeZCf8kXotYBSlhC68tvuv6fPhFgfbqwdoF8Ab6r50cAQXJLOPl9qRCYtKYgz4r8ZBYzPIOVg3zZBU8JRcTmgoWU9DAphsWB3xQHQuZCMYZAMs3YHukOK567GUQeZCxOw8oZBnavnaqc0KukT0GzweRB2VC4CD5a6Vj5EsiJnZCjYuZCrffoha5WCkRRyUryook9syNTQ2cexsObVyhMVpRRc7X74BxbCWuzLZAvbZA6ZAb6zIZCHadhUWKX30dpYd1elqZAWuygnVC8pZBQyFG0YET498DAfs"; // tu token de Meta "EAAeZCf8kXotYBSuVCLO7smu3jGxv7qqndFn3OZB6E55QZBRKB2ZCPmOkylVfseI8PuZBzGBIrGa3QO0hUJZCGq7GwwJBgaxhu4A07LJZCOna82ZAQZAYZBljlQVApTurK1Hj0YHVZA4cnSdQa5xKmoYBa8YTuzyqrC1ZC2s9qbIvWHImUkVUgG2ps7F25ZAZCMISympdL1c34iO2IDLW2NGndy3o4E11K0c1FA3RFTCQJJXPmuddK360KLz5Tpj8BOTZC12FztytNQkwqpHZBBdpCpJfrOyQy546"; // tu token de Meta
private readonly apiVersion = "v25.0"; private readonly apiVersion = "v25.0";
get baseUrl(): string { get baseUrl(): string {
@@ -51,9 +51,9 @@ export class SendEmailByContentController extends Controller {
} }
} }
@Route("notifications/send-wap") @Route("notifications/send-wap")
@Middlewares([rateLimiter, systemTokenMiddleware]) @Middlewares([rateLimiter, systemTokenMiddleware])
export class SendWapByContentController extends Controller { export class SendWapByContentController extends Controller {
@SuccessResponse(200, "Done") @SuccessResponse(200, "Done")
@Post() @Post()
public async sendWapByContent(@Body() requestBody: SendWapByContentParams): Promise<ApiVoidResult> { public async sendWapByContent(@Body() requestBody: SendWapByContentParams): Promise<ApiVoidResult> {
@@ -70,11 +70,38 @@ export class SendEmailByContentController extends Controller {
success: true, success: true,
}; };
} }
} }
@Route("notifications/send-whatsapp-template") /**
@Middlewares([rateLimiter, systemTokenMiddleware]) * TEMPORARY TEST ENDPOINT — remove after testing meta_wap integration
export class SendWhatsAppTemplateController extends Controller { * No auth required. Just for curl testing sendWhatsAppTemplate flow.
*/
@Route("notifications/test-meta-send")
export class TestMetaSendController extends Controller {
@SuccessResponse(200, "Done")
@Post()
public async testMetaSend(@Body() requestBody: SendWhatsAppTemplateParams): Promise<ApiVoidResult> {
try {
await NotificationsManager.sendWhatsAppTemplate({
phoneNumber: requestBody.phoneNumber,
templateName: requestBody.templateName,
languageCode: requestBody.languageCode,
templateVariables: requestBody.templateVariables,
});
this.setStatus(200);
return { message: "Test sent successfully", success: true };
} catch (error) {
const msg = error instanceof Error ? error.message : String(error);
this.setStatus(500);
return { message: `Test failed: ${msg}`, success: false };
}
}
}
@Route("notifications/send-whatsapp-template")
@Middlewares([rateLimiter, systemTokenMiddleware])
export class SendWhatsAppTemplateController extends Controller {
@SuccessResponse(200, "Done") @SuccessResponse(200, "Done")
@Post() @Post()
public async sendWhatsAppTemplate(@Body() requestBody: SendWhatsAppTemplateParams): Promise<ApiVoidResult> { public async sendWhatsAppTemplate(@Body() requestBody: SendWhatsAppTemplateParams): Promise<ApiVoidResult> {
@@ -91,4 +118,4 @@ export class SendEmailByContentController extends Controller {
success: true, success: true,
}; };
} }
} }