This commit is contained in:
2025-12-14 11:57:35 +03:30
parent 1d4a50f91f
commit 2f21791e23
2 changed files with 22 additions and 1 deletions
@@ -50,6 +50,7 @@ export class NotificationService {
})),
);
}
// add sms notifications to queue
if (preference?.channels?.includes(NotifChannelEnum.SMS)) {
await this.queueService.addBulkSmsNotifications(
@@ -140,6 +141,7 @@ export class NotificationService {
},
);
}
async findByAdminAndRestaurant(adminId: string, restaurantId: string, limit = 50): Promise<Notification[]> {
return this.em.find(
Notification,
+20 -1
View File
@@ -32,10 +32,11 @@ export class SmsService {
name,
value: value.toString(),
}));
const cleanedPhone = this.formatPhone(phone);
const smsData: ISmsBodyParameters = {
Parameters: parametersArray,
Mobile: phone,
Mobile: cleanedPhone,
TemplateId: templateId,
};
@@ -57,4 +58,22 @@ export class SmsService {
throw new HttpException('The SMS was not sent. Please try again later.', HttpStatus.BAD_GATEWAY);
}
}
formatPhone(phone: string): string {
// remove spaces, dashes, parentheses
phone = phone.replace(/[^\d+]/g, '');
if (phone.startsWith('+98')) {
return phone;
}
if (phone.startsWith('98')) {
return `+${phone}`;
}
if (phone.startsWith('0')) {
return `+98${phone.slice(1)}`;
}
return `+98${phone}`;
}
}