From da79cb5acd43b9846640ea2071280f8295f6bc0e Mon Sep 17 00:00:00 2001 From: ghost2023 Date: Sun, 2 Aug 2026 13:20:25 +0300 Subject: [PATCH] fix: opt --- .../src/modules/otp/otp.service.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/edr-freight-api/src/modules/otp/otp.service.ts b/apps/edr-freight-api/src/modules/otp/otp.service.ts index 557548b00..d5688e1c2 100644 --- a/apps/edr-freight-api/src/modules/otp/otp.service.ts +++ b/apps/edr-freight-api/src/modules/otp/otp.service.ts @@ -5,7 +5,7 @@ import { randomInt } from "node:crypto"; import { OtpRepository } from "./otp.repository"; -import { SmsClientService } from "../notifications/sms-client.service"; +import { NotificationsService } from "../notifications/notifications.service"; import { EmailClientService } from "../notifications/email-client.service"; /** @@ -95,7 +95,7 @@ export class OtpService { logger = new Logger(OtpService.name); constructor( private readonly otpRepository: OtpRepository, - private readonly smsClient: SmsClientService, + private readonly notifications: NotificationsService, private readonly emailClient: EmailClientService, ) { } @@ -263,17 +263,24 @@ export class OtpService { } } - /** SMS half of {@link dispatchEmail}; same swallow-and-report contract. */ + /** + * SMS half of {@link dispatchEmail}; same swallow-and-report contract. Sent + * via NotificationsService's direct-HTTP Ozeking strategy — the same + * transport the notification system uses — rather than the RabbitMQ + * `SMS_SERVICE` queue, so `queued: true` here means the gateway accepted the + * request, not just that a broker took ownership of the message. + */ private async dispatchSms( phone: string, otp: string, ): Promise { try { - const { queued } = await this.smsClient.sendSms({ - to: phone, - message: `Your verification code is ${otp}`, - }); - return { channel: "sms", queued }; + await this.notifications.directSend( + "sms", + phone, + `Your verification code is ${otp}`, + ); + return { channel: "sms", queued: true }; } catch (error) { return { channel: "sms",