in-app notif
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-06-28 23:18:18 +03:30
parent 604447d3e8
commit 7e7f49a96b
2 changed files with 28 additions and 9 deletions
@@ -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)) {