diff --git a/notification-sender/src/Models/Jobs/NotificationJob.Adapter.Mongoose.ts b/notification-sender/src/Models/Jobs/NotificationJob.Adapter.Mongoose.ts index 4346be0..a9b2730 100644 --- a/notification-sender/src/Models/Jobs/NotificationJob.Adapter.Mongoose.ts +++ b/notification-sender/src/Models/Jobs/NotificationJob.Adapter.Mongoose.ts @@ -20,6 +20,9 @@ export interface NotificationJobPayload { wapMessage?: string; systemSubject?: string; systemMessage?: string; + templateName?: string; + languageCode?: string; + templateVariables?: string[]; } export interface INotificationJob { diff --git a/server/src/Models/NotificationJobs/NotificationJobs.Interface.ts b/server/src/Models/NotificationJobs/NotificationJobs.Interface.ts index 083b896..665164e 100644 --- a/server/src/Models/NotificationJobs/NotificationJobs.Interface.ts +++ b/server/src/Models/NotificationJobs/NotificationJobs.Interface.ts @@ -28,6 +28,9 @@ export interface NotificationJobPayload { wapMessage?: string; systemSubject?: string; systemMessage?: string; + templateName?: string; + languageCode?: string; + templateVariables?: string[]; } export interface INotificationJob { diff --git a/server/src/Models/Notifications/Notifications.Adapter.Meta.ts b/server/src/Models/Notifications/Notifications.Adapter.Meta.ts index 67ca123..b4719d6 100644 --- a/server/src/Models/Notifications/Notifications.Adapter.Meta.ts +++ b/server/src/Models/Notifications/Notifications.Adapter.Meta.ts @@ -5,7 +5,7 @@ export class NotificationsMetaAdapter implements INotificationsAdapter { - await NotificationsManager.sendWap({ - phoneNumber: requestBody.phoneNumber, - message: requestBody.message, - companyId: requestBody.companyId, - sessionUser: requestBody.sessionUser, - }); +@Route("notifications/send-wap") +@Middlewares([rateLimiter, systemTokenMiddleware]) +export class SendWapByContentController extends Controller { + @SuccessResponse(200, "Done") + @Post() + public async sendWapByContent(@Body() requestBody: SendWapByContentParams): Promise { + await NotificationsManager.sendWap({ + phoneNumber: requestBody.phoneNumber, + message: requestBody.message, + companyId: requestBody.companyId, + sessionUser: requestBody.sessionUser, + }); - this.setStatus(200); - return { - message: "Done", - success: true, - }; - } + this.setStatus(200); + return { + message: "Done", + success: true, + }; } +} - @Route("notifications/send-whatsapp-template") - @Middlewares([rateLimiter, systemTokenMiddleware]) - export class SendWhatsAppTemplateController extends Controller { - @SuccessResponse(200, "Done") - @Post() - public async sendWhatsAppTemplate(@Body() requestBody: SendWhatsAppTemplateParams): Promise { +/** + * TEMPORARY TEST ENDPOINT — remove after testing meta_wap integration + * 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 { + try { await NotificationsManager.sendWhatsAppTemplate({ phoneNumber: requestBody.phoneNumber, templateName: requestBody.templateName, @@ -86,9 +90,32 @@ export class SendEmailByContentController extends Controller { }); this.setStatus(200); - return { - message: "Done", - success: true, - }; + 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") + @Post() + public async sendWhatsAppTemplate(@Body() requestBody: SendWhatsAppTemplateParams): Promise { + await NotificationsManager.sendWhatsAppTemplate({ + phoneNumber: requestBody.phoneNumber, + templateName: requestBody.templateName, + languageCode: requestBody.languageCode, + templateVariables: requestBody.templateVariables, + }); + + this.setStatus(200); + return { + message: "Done", + success: true, + }; + } +}