From 8209f4ac828d609f226cdf0d1de1868ec3da7d91 Mon Sep 17 00:00:00 2001 From: "Kyryll O." Date: Thu, 18 Jun 2026 16:32:01 +0300 Subject: [PATCH] fix: sendNotification publishes directly to exchange instead of NestJS RMQ client sendToQueue --- package.json | 2 +- src/backend/services/core.service.ts | 32 +++++++++++++++++++++------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index eef5409..d40959f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@erp/plugin-sdk", - "version": "1.11.0", + "version": "1.11.1", "main": "dist/index.js", "types": "dist/index.d.ts", "bin": { diff --git a/src/backend/services/core.service.ts b/src/backend/services/core.service.ts index aa8bcea..69346ee 100644 --- a/src/backend/services/core.service.ts +++ b/src/backend/services/core.service.ts @@ -406,14 +406,30 @@ export class CoreService { } async sendNotification(payload: { userId: number | null; title: string; message: string; icon?: string; image?: string; details?: any }): Promise { - await this.emit('system.notification.send', { - userId: payload.userId, - title: payload.title, - message: payload.message, - icon: payload.icon, - image: payload.image, - details: payload.details, - }); + try { + const conn = await amqp.connect(this.getRMQUrl()); + const ch = await conn.createChannel(); + await ch.assertExchange('system_events', 'topic', { durable: true }); + const eventData = { + eventId: uuidv4(), + pattern: 'system.notification.send', + payload: { + userId: payload.userId, + title: payload.title, + message: payload.message, + icon: payload.icon, + image: payload.image, + details: payload.details, + }, + source: this.serviceName, + timestamp: Date.now(), + }; + ch.publish('system_events', 'system.notification.send', Buffer.from(JSON.stringify(eventData))); + await ch.close(); + await conn.close(); + } catch (err: any) { + this.logger.error(`[sendNotification] Failed: ${err.message}`); + } } getDbName(): string {