update
This commit is contained in:
@@ -27,18 +27,18 @@ export class NotificationService {
|
||||
const notifications = await this.createAdminBulkNotifications(
|
||||
recipients.map(recipient => ({
|
||||
restaurantId,
|
||||
title: message.subject,
|
||||
content: message.body,
|
||||
title: message.title,
|
||||
content: message.content,
|
||||
adminId: 'adminId' in recipient ? recipient.adminId : null,
|
||||
userId: 'userId' in recipient ? recipient.userId : null,
|
||||
})),
|
||||
);
|
||||
|
||||
// get admin prefrences
|
||||
const preference = await this.preferenceService.findByRestaurantAndType(restaurantId, message.subject);
|
||||
const preference = await this.preferenceService.findByRestaurantAndType(restaurantId, message.title);
|
||||
|
||||
if (preference?.channels?.length === 0) {
|
||||
this.logger.warn(`Notification type is NONE for restaurant ${restaurantId}, title ${message.subject}`);
|
||||
this.logger.warn(`Notification type is NONE for restaurant ${restaurantId}, title ${message.title}`);
|
||||
return notifications;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ export class NotificationService {
|
||||
this.notificationGateway.sendInAppNotification(
|
||||
{ adminId: recipient.adminId, restaurantId },
|
||||
{
|
||||
subject: message.subject,
|
||||
body: message.body,
|
||||
subject: message.title,
|
||||
body: message.content,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ export class NotificationService {
|
||||
// await this.queueService.addPushNotification(job);
|
||||
// }
|
||||
|
||||
this.logger.log(`Queued notification for restaurant ${restaurantId}, title ${message.subject}`);
|
||||
this.logger.log(`Queued notification for restaurant ${restaurantId}, title ${message.title}`);
|
||||
|
||||
return notifications;
|
||||
}
|
||||
@@ -162,4 +162,14 @@ export class NotificationService {
|
||||
},
|
||||
);
|
||||
}
|
||||
async findByAdminAndRestaurant(adminId: string, restaurantId: string, limit = 50): Promise<Notification[]> {
|
||||
return this.em.find(
|
||||
Notification,
|
||||
{ admin: { id: adminId }, restaurant: { id: restaurantId } },
|
||||
{
|
||||
orderBy: { createdAt: 'DESC' },
|
||||
limit,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user