fix: add notif type to create notification
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { IsNotEmpty, IsString, IsUUID } from "class-validator";
|
import { IsEnum, IsNotEmpty, IsString, IsUUID } from "class-validator";
|
||||||
|
|
||||||
import { NotificationMessage } from "../../../common/enums/message.enum";
|
import { NotificationMessage } from "../../../common/enums/message.enum";
|
||||||
|
import { NotifType } from "../../settings/enums/notif-settings.enum";
|
||||||
|
|
||||||
export class CreateNotificationDto {
|
export class CreateNotificationDto {
|
||||||
@IsNotEmpty({ message: NotificationMessage.TITLE_IS_REQUIRED })
|
@IsNotEmpty({ message: NotificationMessage.TITLE_IS_REQUIRED })
|
||||||
@@ -15,4 +16,8 @@ export class CreateNotificationDto {
|
|||||||
@IsString({ message: NotificationMessage.USERID_IS_STRING })
|
@IsString({ message: NotificationMessage.USERID_IS_STRING })
|
||||||
@IsUUID("4", { message: NotificationMessage.USERID_IS_UUID })
|
@IsUUID("4", { message: NotificationMessage.USERID_IS_UUID })
|
||||||
recipientId: string;
|
recipientId: string;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
@IsEnum(NotifType)
|
||||||
|
type: NotifType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Column, Entity, ManyToOne } from "typeorm";
|
import { Column, Entity, ManyToOne } from "typeorm";
|
||||||
|
|
||||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||||
|
import { NotifType } from "../../settings/enums/notif-settings.enum";
|
||||||
import { User } from "../../users/entities/user.entity";
|
import { User } from "../../users/entities/user.entity";
|
||||||
import { NotificationType } from "../enums/notification-type.enum";
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Notification extends BaseEntity {
|
export class Notification extends BaseEntity {
|
||||||
@@ -12,8 +12,8 @@ export class Notification extends BaseEntity {
|
|||||||
@Column({ type: "text", nullable: false })
|
@Column({ type: "text", nullable: false })
|
||||||
message: string;
|
message: string;
|
||||||
|
|
||||||
@Column({ type: "enum", enum: NotificationType, default: NotificationType.LOGIN })
|
@Column({ type: "enum", enum: NotifType, nullable: false })
|
||||||
type: NotificationType;
|
type: NotifType;
|
||||||
|
|
||||||
@Column({ type: "boolean", default: false })
|
@Column({ type: "boolean", default: false })
|
||||||
isRead: boolean;
|
isRead: boolean;
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
export enum NotificationType {
|
|
||||||
LOGIN = "LOGIN",
|
|
||||||
PASSWORD_CHANGED = "PASSWORD_CHANGED",
|
|
||||||
WALLET_CHARGED = "WALLER_CHARGED",
|
|
||||||
}
|
|
||||||
@@ -124,7 +124,7 @@ export class NotificationsService {
|
|||||||
await this.smsService.sendLoginSms(sendNotifData.userPhone, loginDate);
|
await this.smsService.sendLoginSms(sendNotifData.userPhone, loginDate);
|
||||||
//send email too
|
//send email too
|
||||||
}
|
}
|
||||||
return this.createNotification({ title: NotificationMessage.LOGIN, message, recipientId });
|
return this.createNotification({ title: NotificationMessage.LOGIN, type: NotifType.USER_LOGIN, message, recipientId });
|
||||||
}
|
}
|
||||||
|
|
||||||
//************************ */
|
//************************ */
|
||||||
@@ -147,7 +147,10 @@ export class NotificationsService {
|
|||||||
);
|
);
|
||||||
//send email too
|
//send email too
|
||||||
}
|
}
|
||||||
return this.createNotification({ title: NotificationMessage.INVOICE_CREATION, message, recipientId }, queryRunner);
|
return this.createNotification(
|
||||||
|
{ title: NotificationMessage.INVOICE_CREATION, type: NotifType.CREATE_INVOICE, message, recipientId },
|
||||||
|
queryRunner,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
//************************ */
|
//************************ */
|
||||||
|
|
||||||
@@ -163,7 +166,7 @@ export class NotificationsService {
|
|||||||
await this.smsService.sendAnnouncementSms(data.userPhone, data.title, data.description, dateFormat(data.date));
|
await this.smsService.sendAnnouncementSms(data.userPhone, data.title, data.description, dateFormat(data.date));
|
||||||
//send email too
|
//send email too
|
||||||
}
|
}
|
||||||
return this.createNotification({ title: NotificationMessage.ANNOUNCEMENT, message, recipientId });
|
return this.createNotification({ title: NotificationMessage.ANNOUNCEMENT, type: NotifType.ANNOUNCEMENT, message, recipientId });
|
||||||
}
|
}
|
||||||
|
|
||||||
//************************ */
|
//************************ */
|
||||||
@@ -185,7 +188,7 @@ export class NotificationsService {
|
|||||||
);
|
);
|
||||||
//send email too
|
//send email too
|
||||||
}
|
}
|
||||||
return this.createNotification({ title: NotificationMessage.WALLET_CHARGE, message, recipientId });
|
return this.createNotification({ title: NotificationMessage.WALLET_CHARGE, type: NotifType.WALLET_CHARGE, message, recipientId });
|
||||||
}
|
}
|
||||||
|
|
||||||
//************************ */
|
//************************ */
|
||||||
@@ -208,7 +211,7 @@ export class NotificationsService {
|
|||||||
);
|
);
|
||||||
//send email too
|
//send email too
|
||||||
}
|
}
|
||||||
return this.createNotification({ title: NotificationMessage.WALLET_DEDUCTION, message, recipientId });
|
return this.createNotification({ title: NotificationMessage.WALLET_DEDUCTION, type: NotifType.WALLET_DEDUCTION, message, recipientId });
|
||||||
}
|
}
|
||||||
|
|
||||||
// //************************ */
|
// //************************ */
|
||||||
@@ -225,7 +228,7 @@ export class NotificationsService {
|
|||||||
await this.smsService.sendAnswerTicketSms(data.userPhone, data.ticketId, data.subject);
|
await this.smsService.sendAnswerTicketSms(data.userPhone, data.ticketId, data.subject);
|
||||||
//send email too
|
//send email too
|
||||||
}
|
}
|
||||||
return this.createNotification({ title: NotificationMessage.ANSWER_TICKET, message, recipientId });
|
return this.createNotification({ title: NotificationMessage.ANSWER_TICKET, type: NotifType.ANSWER_TICKET, message, recipientId });
|
||||||
}
|
}
|
||||||
|
|
||||||
// //************************ */
|
// //************************ */
|
||||||
@@ -242,7 +245,7 @@ export class NotificationsService {
|
|||||||
await this.smsService.sendCreateTicketSms(data.userPhone, data.ticketId, data.subject, dateFormat(data.date));
|
await this.smsService.sendCreateTicketSms(data.userPhone, data.ticketId, data.subject, dateFormat(data.date));
|
||||||
//send email too
|
//send email too
|
||||||
}
|
}
|
||||||
return this.createNotification({ title: NotificationMessage.CREATE_TICKET, message, recipientId });
|
return this.createNotification({ title: NotificationMessage.CREATE_TICKET, type: NotifType.CREATE_TICKET, message, recipientId });
|
||||||
}
|
}
|
||||||
|
|
||||||
//************************ */
|
//************************ */
|
||||||
|
|||||||
Reference in New Issue
Block a user