mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
@@ -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<DispatchOutcome> {
|
||||
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",
|
||||
|
||||
Reference in New Issue
Block a user