This commit is contained in:
@@ -27,6 +27,11 @@ export class InAppProcessor extends WorkerHost {
|
|||||||
|
|
||||||
this.logger.log(`Processing InApp notification - Recipient: ${JSON.stringify(recipient)}, subject: ${subject}`);
|
this.logger.log(`Processing InApp notification - Recipient: ${JSON.stringify(recipient)}, subject: ${subject}`);
|
||||||
|
|
||||||
|
if (!recipient.adminId) {
|
||||||
|
this.logger.warn(`Skipping in-app notification job ${job.id}: missing adminId`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.notificationsGateway.sendInAppNotification(
|
this.notificationsGateway.sendInAppNotification(
|
||||||
{ adminId: recipient.adminId, restaurantId: recipient.restaurantId },
|
{ adminId: recipient.adminId, restaurantId: recipient.restaurantId },
|
||||||
|
|||||||
@@ -43,16 +43,30 @@ export class NotificationService {
|
|||||||
return notifications;
|
return notifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send in app notification
|
// send in app notification (admins only — user records must not emit to admin socket rooms)
|
||||||
if (preference?.channels?.includes(NotifChannelEnum.IN_APP)) {
|
if (preference?.channels?.includes(NotifChannelEnum.IN_APP)) {
|
||||||
await this.queueService.addBulkInAppNotifications(
|
const inAppJobs = recipients.flatMap((recipient, index) => {
|
||||||
notifications.map(notification => ({
|
if (!('adminId' in recipient) || !recipient.adminId) {
|
||||||
recipient: { adminId: notification.admin?.id || '', restaurantId },
|
return [];
|
||||||
subject: message.title,
|
}
|
||||||
body: message.content,
|
|
||||||
notificationId: notification.id,
|
return [
|
||||||
})),
|
{
|
||||||
);
|
recipient: { adminId: recipient.adminId, restaurantId },
|
||||||
|
subject: message.title,
|
||||||
|
body: message.content,
|
||||||
|
notificationId: notifications[index]!.id,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
if (inAppJobs.length > 0) {
|
||||||
|
await this.queueService.addBulkInAppNotifications(inAppJobs);
|
||||||
|
} else {
|
||||||
|
this.logger.warn(
|
||||||
|
`No admin recipients for in-app notification: restaurant ${restaurantId}, title ${message.title}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add sms notifications to queue
|
// add sms notifications to queue
|
||||||
|
|||||||
Reference in New Issue
Block a user