Skip to content

Commit

Permalink
Merge branch 'release/1.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidsonGomes committed Mar 27, 2024
2 parents 43bdbf1 + 9f1003e commit b87558d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/whatsapp/services/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class BaileysStartupService extends WAStartupService {
if (this.localProxy.enabled) {
this.logger.info('Proxy enabled: ' + this.localProxy.proxy);

if (this.localProxy.proxy.host.includes('proxyscrape')) {
if (this.localProxy?.proxy?.host?.includes('proxyscrape')) {
try {
const response = await axios.get(this.localProxy.proxy.host);
const text = response.data;
Expand Down
25 changes: 21 additions & 4 deletions src/whatsapp/services/whatsapp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,18 @@ export class WAStartupService {
};
}

private assertExchangeAsync = (channel, exchangeName, exchangeType, options) => {
return new Promise((resolve, reject) => {
channel.assertExchange(exchangeName, exchangeType, options, (error, ok) => {
if (error) {
reject(error);
} else {
resolve(ok);
}
});
});
};

public async sendDataWebhook<T = any>(event: Events, data: T, local = true) {
const webhookGlobal = this.configService.get<Webhook>('WEBHOOK');
const webhookLocal = this.localWebhook.events;
Expand All @@ -687,22 +699,27 @@ export class WAStartupService {
if (Array.isArray(rabbitmqLocal) && rabbitmqLocal.includes(we)) {
const exchangeName = this.instanceName ?? 'evolution_exchange';

amqp.assertExchange(exchangeName, 'topic', {
// await amqp.assertExchange(exchangeName, 'topic', {
// durable: true,
// autoDelete: false,
// });

await this.assertExchangeAsync(amqp, exchangeName, 'topic', {
durable: true,
autoDelete: false,
});

const queueName = `${this.instanceName}.${event}`;

amqp.assertQueue(queueName, {
await amqp.assertQueue(queueName, {
durable: true,
autoDelete: false,
arguments: {
'x-queue-type': 'quorum',
},
});

amqp.bindQueue(queueName, exchangeName, event);
await amqp.bindQueue(queueName, exchangeName, event);

const message = {
event,
Expand All @@ -717,7 +734,7 @@ export class WAStartupService {
message['apikey'] = instanceApikey;
}

amqp.publish(exchangeName, event, Buffer.from(JSON.stringify(message)));
await amqp.publish(exchangeName, event, Buffer.from(JSON.stringify(message)));

if (this.configService.get<Log>('LOG').LEVEL.includes('WEBHOOKS')) {
const logData = {
Expand Down

0 comments on commit b87558d

Please sign in to comment.