diff --git a/src/libs/amqp.server.ts b/src/libs/amqp.server.ts index 21357257..172d76a7 100644 --- a/src/libs/amqp.server.ts +++ b/src/libs/amqp.server.ts @@ -44,7 +44,7 @@ export const getAMQP = (): amqp.Channel | null => { export const initQueues = (instanceName: string, events: string[]) => { console.log('initQueues', instanceName, events); - if (!events.length) return; + if (!events || !events.length) return; const queues = events.map((event) => { return `${event.replace(/_/g, '.').toLowerCase()}`; diff --git a/src/whatsapp/controllers/instance.controller.ts b/src/whatsapp/controllers/instance.controller.ts index ed466284..257d5f05 100644 --- a/src/whatsapp/controllers/instance.controller.ts +++ b/src/whatsapp/controllers/instance.controller.ts @@ -229,7 +229,7 @@ export class InstanceController { 'CHAMA_AI_ACTION', ]; } else { - newEvents = events; + newEvents = rabbitmq_events; } this.rabbitmqService.create(instance, { enabled: true, @@ -237,8 +237,6 @@ export class InstanceController { }); rabbitmqEvents = (await this.rabbitmqService.find(instance)).events; - - initQueues(instance.instanceName, rabbitmqEvents); } catch (error) { this.logger.log(error); }