mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 11:55:42 +00:00
fix: opt
This commit is contained in:
@@ -5,7 +5,7 @@ import { randomInt } from "node:crypto";
|
|||||||
|
|
||||||
import { OtpRepository } from "./otp.repository";
|
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";
|
import { EmailClientService } from "../notifications/email-client.service";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,7 +95,7 @@ export class OtpService {
|
|||||||
logger = new Logger(OtpService.name);
|
logger = new Logger(OtpService.name);
|
||||||
constructor(
|
constructor(
|
||||||
private readonly otpRepository: OtpRepository,
|
private readonly otpRepository: OtpRepository,
|
||||||
private readonly smsClient: SmsClientService,
|
private readonly notifications: NotificationsService,
|
||||||
private readonly emailClient: EmailClientService,
|
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(
|
private async dispatchSms(
|
||||||
phone: string,
|
phone: string,
|
||||||
otp: string,
|
otp: string,
|
||||||
): Promise<DispatchOutcome> {
|
): Promise<DispatchOutcome> {
|
||||||
try {
|
try {
|
||||||
const { queued } = await this.smsClient.sendSms({
|
await this.notifications.directSend(
|
||||||
to: phone,
|
"sms",
|
||||||
message: `Your verification code is ${otp}`,
|
phone,
|
||||||
});
|
`Your verification code is ${otp}`,
|
||||||
return { channel: "sms", queued };
|
);
|
||||||
|
return { channel: "sms", queued: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
channel: "sms",
|
channel: "sms",
|
||||||
|
|||||||
Reference in New Issue
Block a user