feat: sms using twillio

This commit is contained in:
Abdalhamid Alhamad
2024-12-29 09:44:12 +03:00
parent 0750509a85
commit a7028fa64c
8 changed files with 122 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import { PageOptionsRequestDto } from '~/core/dtos';
import { Notification } from '../entities';
import { NotificationsRepository } from '../repositories';
import { FirebaseService } from './firebase.service';
import { TwilioService } from './twilio.service';
@Injectable()
export class NotificationsService {
@ -11,6 +12,7 @@ export class NotificationsService {
private readonly deviceService: DeviceService,
private readonly firebaseService: FirebaseService,
private readonly notificationRepository: NotificationsRepository,
private readonly twilioService: TwilioService,
) {}
async sendPushNotification(userId: string, title: string, body: string) {
@ -25,6 +27,10 @@ export class NotificationsService {
return this.firebaseService.sendNotification(tokens, title, body);
}
async sendSMS(to: string, body: string) {
await this.twilioService.sendSMS(to, body);
}
async getNotifications(userId: string, pageOptionsDto: PageOptionsRequestDto) {
const [[notifications, count], unreadCount] = await Promise.all([
this.notificationRepository.getNotifications(userId, pageOptionsDto),