chore: add new method for sms service and notification service
This commit is contained in:
@@ -50,3 +50,35 @@ export interface IPaymentNotificationData extends IBaseNotificationData {
|
||||
amount: number;
|
||||
paymentId: string;
|
||||
}
|
||||
|
||||
export interface IBlogCommentNotificationData extends IBaseNotificationData {
|
||||
blogTitle: string;
|
||||
fullName: string;
|
||||
}
|
||||
|
||||
export interface IServiceReviewNotificationData extends IBaseNotificationData {
|
||||
serviceName: string;
|
||||
fullName: string;
|
||||
}
|
||||
|
||||
export interface INewCustomerNotificationData extends IBaseNotificationData {
|
||||
fullName: string;
|
||||
mobile: string;
|
||||
}
|
||||
|
||||
export interface INewSubscriptionNotificationData extends IBaseNotificationData {
|
||||
serviceName: string;
|
||||
fullName: string;
|
||||
date: Date;
|
||||
}
|
||||
|
||||
export interface INewTicketNotificationData extends IBaseNotificationData {
|
||||
ticketId: string;
|
||||
ticketSubject: string;
|
||||
fullName: string;
|
||||
}
|
||||
|
||||
export interface INewCriticismNotificationData extends IBaseNotificationData {
|
||||
title: string;
|
||||
fullName: string;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,14 @@ import { Notification } from "../entities/notification.entity";
|
||||
import {
|
||||
IAnnouncementNotificationData,
|
||||
IBaseNotificationData,
|
||||
IBlogCommentNotificationData,
|
||||
IInvoiceNotificationData,
|
||||
INewCriticismNotificationData,
|
||||
INewCustomerNotificationData,
|
||||
INewSubscriptionNotificationData,
|
||||
INewTicketNotificationData,
|
||||
IPaymentNotificationData,
|
||||
IServiceReviewNotificationData,
|
||||
ISubscriptionNotificationData,
|
||||
ITicketNotificationData,
|
||||
IWalletNotificationData,
|
||||
@@ -441,4 +447,116 @@ export class NotificationsService {
|
||||
queryRunner,
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
|
||||
// Admin notification methods
|
||||
|
||||
//--------------------------------------
|
||||
async createNewBlogCommentNotification(recipientId: string, data: IBlogCommentNotificationData, queryRunner: QueryRunner) {
|
||||
const message = NotificationMessage.NEW_BLOG_COMMENT_MESSAGE.replace("[blogTitle]", data.blogTitle);
|
||||
|
||||
await this.smsService.sendBlogNewCommentSms(data.userPhone, data.blogTitle, data.fullName);
|
||||
if (data.userEmail) {
|
||||
await this.emailService.sendAdminNotificationEmail({
|
||||
userEmail: data.userEmail,
|
||||
title: NotificationMessage.NEW_BLOG_COMMENT,
|
||||
message,
|
||||
});
|
||||
}
|
||||
return this.createNotification(
|
||||
{ title: NotificationMessage.NEW_BLOG_COMMENT, type: NotifType.NEW_BLOG_COMMENT, message, recipientId },
|
||||
queryRunner,
|
||||
);
|
||||
}
|
||||
//************************************************* */
|
||||
async createNewServiceReviewNotification(recipientId: string, data: IServiceReviewNotificationData, queryRunner: QueryRunner) {
|
||||
const message = NotificationMessage.NEW_SERVICE_REVIEW_MESSAGE.replace("[serviceName]", data.serviceName);
|
||||
|
||||
await this.smsService.sendNewServiceReviewSms(data.userPhone, data.serviceName, data.fullName);
|
||||
if (data.userEmail) {
|
||||
await this.emailService.sendAdminNotificationEmail({
|
||||
userEmail: data.userEmail,
|
||||
title: NotificationMessage.NEW_SERVICE_REVIEW,
|
||||
message,
|
||||
});
|
||||
}
|
||||
|
||||
return this.createNotification(
|
||||
{ title: NotificationMessage.NEW_SERVICE_REVIEW, type: NotifType.NEW_SERVICE_REVIEW, message, recipientId },
|
||||
queryRunner,
|
||||
);
|
||||
}
|
||||
//************************************************* */
|
||||
|
||||
async createNewCustomerNotification(recipientId: string, data: INewCustomerNotificationData, queryRunner: QueryRunner) {
|
||||
const message = NotificationMessage.NEW_CUSTOMER_MESSAGE.replace("[fullName]", data.fullName);
|
||||
|
||||
await this.smsService.sendNewCustomerSms(data.userPhone, data.fullName);
|
||||
if (data.userEmail) {
|
||||
await this.emailService.sendAdminNotificationEmail({
|
||||
userEmail: data.userEmail,
|
||||
title: NotificationMessage.NEW_CUSTOMER,
|
||||
message,
|
||||
});
|
||||
}
|
||||
return this.createNotification(
|
||||
{ title: NotificationMessage.NEW_CUSTOMER, type: NotifType.NEW_CUSTOMER, message, recipientId },
|
||||
queryRunner,
|
||||
);
|
||||
}
|
||||
//************************************************* */
|
||||
|
||||
async createNewSubscriptionNotification(recipientId: string, data: INewSubscriptionNotificationData, queryRunner: QueryRunner) {
|
||||
const message = NotificationMessage.NEW_SUBSCRIPTION_MESSAGE.replace("[serviceName]", data.serviceName);
|
||||
|
||||
await this.smsService.sendNewSubscriptionSms(data.userPhone, data.serviceName, data.fullName, dateFormat(data.date));
|
||||
if (data.userEmail) {
|
||||
await this.emailService.sendAdminNotificationEmail({
|
||||
userEmail: data.userEmail,
|
||||
title: NotificationMessage.NEW_SUBSCRIPTION,
|
||||
message,
|
||||
});
|
||||
}
|
||||
return this.createNotification(
|
||||
{ title: NotificationMessage.NEW_SUBSCRIPTION, type: NotifType.NEW_SUBSCRIPTION, message, recipientId },
|
||||
queryRunner,
|
||||
);
|
||||
}
|
||||
//************************************************* */
|
||||
|
||||
async createNewTicketNotification(recipientId: string, data: INewTicketNotificationData, queryRunner: QueryRunner) {
|
||||
const message = NotificationMessage.NEW_TICKET_MESSAGE.replace("[ticketSubject]", data.ticketSubject);
|
||||
|
||||
await this.smsService.sendGlobalNewTicketSms(data.userPhone, data.ticketId, data.ticketSubject, data.fullName);
|
||||
if (data.userEmail) {
|
||||
await this.emailService.sendAdminNotificationEmail({
|
||||
userEmail: data.userEmail,
|
||||
title: NotificationMessage.NEW_TICKET,
|
||||
message,
|
||||
});
|
||||
}
|
||||
return this.createNotification(
|
||||
{ title: NotificationMessage.NEW_TICKET, type: NotifType.NEW_TICKET, message, recipientId },
|
||||
queryRunner,
|
||||
);
|
||||
}
|
||||
//************************************************* */
|
||||
|
||||
async createNewCriticismNotification(recipientId: string, data: INewCriticismNotificationData, queryRunner: QueryRunner) {
|
||||
const message = NotificationMessage.NEW_CRITICISM_MESSAGE.replace("[title]", data.title);
|
||||
|
||||
await this.smsService.sendNewCriticismSms(data.userPhone, data.title, data.fullName);
|
||||
if (data.userEmail) {
|
||||
await this.emailService.sendAdminNotificationEmail({
|
||||
userEmail: data.userEmail,
|
||||
title: NotificationMessage.NEW_CRITICISM,
|
||||
message,
|
||||
});
|
||||
}
|
||||
return this.createNotification(
|
||||
{ title: NotificationMessage.NEW_CRITICISM, type: NotifType.NEW_CRITICISM, message, recipientId },
|
||||
queryRunner,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user