Merge branch 'release/2.2.2'

This commit is contained in:
Davidson Gomes 2025-01-31 07:13:25 -03:00
commit 14fea2f5e0
7 changed files with 533 additions and 496 deletions

View File

@ -49,6 +49,8 @@ RABBITMQ_URI=amqp://localhost
RABBITMQ_EXCHANGE_NAME=evolution RABBITMQ_EXCHANGE_NAME=evolution
# Global events - By enabling this variable, events from all instances are sent in the same event queue. # Global events - By enabling this variable, events from all instances are sent in the same event queue.
RABBITMQ_GLOBAL_ENABLED=false RABBITMQ_GLOBAL_ENABLED=false
# Prefix key to queue name
RABBITMQ_PREFIX_KEY=evolution
# Choose the events you want to send to RabbitMQ # Choose the events you want to send to RabbitMQ
RABBITMQ_EVENTS_APPLICATION_STARTUP=false RABBITMQ_EVENTS_APPLICATION_STARTUP=false
RABBITMQ_EVENTS_INSTANCE_CREATE=false RABBITMQ_EVENTS_INSTANCE_CREATE=false

View File

@ -1,3 +1,13 @@
# 2.2.2 (2025-01-31 06:55)
### Features
* Added prefix key to queue name in RabbitMQ
### Fixed
* Update Baileys Version
# 2.2.1 (2025-01-22 14:37) # 2.2.1 (2025-01-22 14:37)
### Features ### Features

View File

@ -3,7 +3,7 @@ FROM node:20-alpine AS builder
RUN apk update && \ RUN apk update && \
apk add git ffmpeg wget curl bash openssl apk add git ffmpeg wget curl bash openssl
LABEL version="2.2.1" description="Api to control whatsapp features through http requests." LABEL version="2.2.2" description="Api to control whatsapp features through http requests."
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes" LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
LABEL contact="contato@atendai.com" LABEL contact="contato@atendai.com"

1000
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "evolution-api", "name": "evolution-api",
"version": "2.2.1", "version": "2.2.2",
"description": "Rest api for communication with WhatsApp", "description": "Rest api for communication with WhatsApp",
"main": "./dist/main.js", "main": "./dist/main.js",
"type": "commonjs", "type": "commonjs",

View File

@ -87,6 +87,7 @@ export class RabbitmqController extends EventController implements EventControll
const rabbitmqLocal = instanceRabbitmq?.events; const rabbitmqLocal = instanceRabbitmq?.events;
const rabbitmqGlobal = configService.get<Rabbitmq>('RABBITMQ').GLOBAL_ENABLED; const rabbitmqGlobal = configService.get<Rabbitmq>('RABBITMQ').GLOBAL_ENABLED;
const rabbitmqEvents = configService.get<Rabbitmq>('RABBITMQ').EVENTS; const rabbitmqEvents = configService.get<Rabbitmq>('RABBITMQ').EVENTS;
const prefixKey = configService.get<Rabbitmq>('RABBITMQ').PREFIX_KEY;
const rabbitmqExchangeName = configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME; const rabbitmqExchangeName = configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME;
const we = event.replace(/[.-]/gm, '_').toUpperCase(); const we = event.replace(/[.-]/gm, '_').toUpperCase();
const logEnabled = configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS'); const logEnabled = configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS');
@ -159,7 +160,9 @@ export class RabbitmqController extends EventController implements EventControll
autoDelete: false, autoDelete: false,
}); });
const queueName = event; const queueName = prefixKey
? `${prefixKey}.${event.replace(/_/g, '.').toLowerCase()}`
: event.replace(/_/g, '.').toLowerCase();
await this.amqpChannel.assertQueue(queueName, { await this.amqpChannel.assertQueue(queueName, {
durable: true, durable: true,
@ -195,6 +198,7 @@ export class RabbitmqController extends EventController implements EventControll
const rabbitmqExchangeName = configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME; const rabbitmqExchangeName = configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME;
const events = configService.get<Rabbitmq>('RABBITMQ').EVENTS; const events = configService.get<Rabbitmq>('RABBITMQ').EVENTS;
const prefixKey = configService.get<Rabbitmq>('RABBITMQ').PREFIX_KEY;
if (!events) { if (!events) {
this.logger.warn('No events to initialize on AMQP'); this.logger.warn('No events to initialize on AMQP');
@ -207,7 +211,10 @@ export class RabbitmqController extends EventController implements EventControll
eventKeys.forEach((event) => { eventKeys.forEach((event) => {
if (events[event] === false) return; if (events[event] === false) return;
const queueName = `${event.replace(/_/g, '.').toLowerCase()}`; const queueName =
prefixKey !== ''
? `${prefixKey}.${event.replace(/_/g, '.').toLowerCase()}`
: `${event.replace(/_/g, '.').toLowerCase()}`;
const exchangeName = rabbitmqExchangeName; const exchangeName = rabbitmqExchangeName;
this.amqpChannel.assertExchange(exchangeName, 'topic', { this.amqpChannel.assertExchange(exchangeName, 'topic', {

View File

@ -97,6 +97,7 @@ export type Rabbitmq = {
EXCHANGE_NAME: string; EXCHANGE_NAME: string;
GLOBAL_ENABLED: boolean; GLOBAL_ENABLED: boolean;
EVENTS: EventsRabbitmq; EVENTS: EventsRabbitmq;
PREFIX_KEY: string;
}; };
export type Sqs = { export type Sqs = {
@ -355,6 +356,7 @@ export class ConfigService {
RABBITMQ: { RABBITMQ: {
ENABLED: process.env?.RABBITMQ_ENABLED === 'true', ENABLED: process.env?.RABBITMQ_ENABLED === 'true',
GLOBAL_ENABLED: process.env?.RABBITMQ_GLOBAL_ENABLED === 'true', GLOBAL_ENABLED: process.env?.RABBITMQ_GLOBAL_ENABLED === 'true',
PREFIX_KEY: process.env?.RABBITMQ_PREFIX_KEY || 'evolution',
EXCHANGE_NAME: process.env?.RABBITMQ_EXCHANGE_NAME || 'evolution_exchange', EXCHANGE_NAME: process.env?.RABBITMQ_EXCHANGE_NAME || 'evolution_exchange',
URI: process.env.RABBITMQ_URI || '', URI: process.env.RABBITMQ_URI || '',
EVENTS: { EVENTS: {