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}`);
|
||||
|
||||
if (!recipient.adminId) {
|
||||
this.logger.warn(`Skipping in-app notification job ${job.id}: missing adminId`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.notificationsGateway.sendInAppNotification(
|
||||
{ adminId: recipient.adminId, restaurantId: recipient.restaurantId },
|
||||
|
||||
@@ -43,17 +43,31 @@ export class NotificationService {
|
||||
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)) {
|
||||
await this.queueService.addBulkInAppNotifications(
|
||||
notifications.map(notification => ({
|
||||
recipient: { adminId: notification.admin?.id || '', restaurantId },
|
||||
const inAppJobs = recipients.flatMap((recipient, index) => {
|
||||
if (!('adminId' in recipient) || !recipient.adminId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
recipient: { adminId: recipient.adminId, restaurantId },
|
||||
subject: message.title,
|
||||
body: message.content,
|
||||
notificationId: notification.id,
|
||||
})),
|
||||
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
|
||||
if (preference?.channels?.includes(NotifChannelEnum.SMS)) {
|
||||
|
||||
Reference in New Issue
Block a user