mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-25 06:37:45 -06:00
Merge pull request #451 from judsonjuniorr/feat/rabbit-per-events
RabbitMQ improvements
This commit is contained in:
@@ -1123,7 +1123,7 @@ export class BaileysStartupService extends WAStartupService {
|
||||
5: 'PLAYED',
|
||||
};
|
||||
for await (const { key, update } of args) {
|
||||
if (settings?.groups_ignore && key.remoteJid.includes('@g.us')) {
|
||||
if (settings?.groups_ignore && key.remoteJid?.includes('@g.us')) {
|
||||
this.logger.verbose('group ignored');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,6 @@ export class BusinessStartupService extends WAStartupService {
|
||||
if (received.contacts) pushName = received.contacts[0].profile.name;
|
||||
|
||||
if (received.messages) {
|
||||
console.log('received?.messages[0]', received?.messages[0]);
|
||||
const key = {
|
||||
id: received.messages[0].id,
|
||||
remoteJid: this.phoneNumber,
|
||||
@@ -772,9 +771,6 @@ export class BusinessStartupService extends WAStartupService {
|
||||
}
|
||||
})();
|
||||
|
||||
console.log('messageSent', messageSent);
|
||||
console.log('message', message);
|
||||
|
||||
const messageRaw: MessageRaw = {
|
||||
key: { fromMe: true, id: messageSent?.messages[0]?.id, remoteJid: this.createJid(number) },
|
||||
//pushName: messageSent.pushName,
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { ROOT_DIR } from '../../config/path.config';
|
||||
import { NotFoundException } from '../../exceptions';
|
||||
import { getAMQP, removeQueues } from '../../libs/amqp.server';
|
||||
import { getAMQP, removeQueues, sendEventData } from '../../libs/amqp.server';
|
||||
import { getIO } from '../../libs/socket.server';
|
||||
import { getSQS, removeQueues as removeQueuesSQS } from '../../libs/sqs.server';
|
||||
import { ChamaaiRaw, IntegrationRaw, ProxyRaw, RabbitmqRaw, SettingsRaw, SqsRaw, TypebotRaw } from '../models';
|
||||
@@ -685,40 +685,13 @@ export class WAStartupService {
|
||||
|
||||
if (amqp) {
|
||||
if (Array.isArray(rabbitmqLocal) && rabbitmqLocal.includes(we)) {
|
||||
const exchangeName = this.instanceName ?? 'evolution_exchange';
|
||||
|
||||
amqp.assertExchange(exchangeName, 'topic', {
|
||||
durable: true,
|
||||
autoDelete: false,
|
||||
assert: true,
|
||||
});
|
||||
|
||||
const queueName = `${this.instanceName}.${event}`;
|
||||
|
||||
amqp.assertQueue(queueName, {
|
||||
durable: true,
|
||||
autoDelete: false,
|
||||
arguments: {
|
||||
'x-queue-type': 'quorum',
|
||||
},
|
||||
});
|
||||
|
||||
amqp.bindQueue(queueName, exchangeName, event);
|
||||
|
||||
const message = {
|
||||
event,
|
||||
instance: this.instance.name,
|
||||
sendEventData({
|
||||
data,
|
||||
server_url: serverUrl,
|
||||
date_time: now,
|
||||
sender: this.wuid,
|
||||
};
|
||||
|
||||
if (expose && instanceApikey) {
|
||||
message['apikey'] = instanceApikey;
|
||||
}
|
||||
|
||||
amqp.publish(exchangeName, event, Buffer.from(JSON.stringify(message)));
|
||||
event,
|
||||
instanceName: this.instanceName,
|
||||
wuid: this.wuid,
|
||||
apiKey: expose && instanceApikey ? instanceApikey : undefined,
|
||||
});
|
||||
|
||||
if (this.configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS')) {
|
||||
const logData = {
|
||||
|
||||
Reference in New Issue
Block a user