Skip to content

Commit b87558d

Browse files
committed
Merge branch 'release/1.7.0'
2 parents 43bdbf1 + 9f1003e commit b87558d

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/whatsapp/services/whatsapp.baileys.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ export class BaileysStartupService extends WAStartupService {
472472
if (this.localProxy.enabled) {
473473
this.logger.info('Proxy enabled: ' + this.localProxy.proxy);
474474

475-
if (this.localProxy.proxy.host.includes('proxyscrape')) {
475+
if (this.localProxy?.proxy?.host?.includes('proxyscrape')) {
476476
try {
477477
const response = await axios.get(this.localProxy.proxy.host);
478478
const text = response.data;

src/whatsapp/services/whatsapp.service.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,18 @@ export class WAStartupService {
663663
};
664664
}
665665

666+
private assertExchangeAsync = (channel, exchangeName, exchangeType, options) => {
667+
return new Promise((resolve, reject) => {
668+
channel.assertExchange(exchangeName, exchangeType, options, (error, ok) => {
669+
if (error) {
670+
reject(error);
671+
} else {
672+
resolve(ok);
673+
}
674+
});
675+
});
676+
};
677+
666678
public async sendDataWebhook<T = any>(event: Events, data: T, local = true) {
667679
const webhookGlobal = this.configService.get<Webhook>('WEBHOOK');
668680
const webhookLocal = this.localWebhook.events;
@@ -687,22 +699,27 @@ export class WAStartupService {
687699
if (Array.isArray(rabbitmqLocal) && rabbitmqLocal.includes(we)) {
688700
const exchangeName = this.instanceName ?? 'evolution_exchange';
689701

690-
amqp.assertExchange(exchangeName, 'topic', {
702+
// await amqp.assertExchange(exchangeName, 'topic', {
703+
// durable: true,
704+
// autoDelete: false,
705+
// });
706+
707+
await this.assertExchangeAsync(amqp, exchangeName, 'topic', {
691708
durable: true,
692709
autoDelete: false,
693710
});
694711

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

697-
amqp.assertQueue(queueName, {
714+
await amqp.assertQueue(queueName, {
698715
durable: true,
699716
autoDelete: false,
700717
arguments: {
701718
'x-queue-type': 'quorum',
702719
},
703720
});
704721

705-
amqp.bindQueue(queueName, exchangeName, event);
722+
await amqp.bindQueue(queueName, exchangeName, event);
706723

707724
const message = {
708725
event,
@@ -717,7 +734,7 @@ export class WAStartupService {
717734
message['apikey'] = instanceApikey;
718735
}
719736

720-
amqp.publish(exchangeName, event, Buffer.from(JSON.stringify(message)));
737+
await amqp.publish(exchangeName, event, Buffer.from(JSON.stringify(message)));
721738

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

0 commit comments

Comments
 (0)