From bc6944736eccd033678f11652467f8e8931c0ad5 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Sun, 18 Feb 2024 07:44:42 -0300 Subject: [PATCH] fix: expose integration in fetch instance --- src/whatsapp/services/monitor.service.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/whatsapp/services/monitor.service.ts b/src/whatsapp/services/monitor.service.ts index 963ea608..bc983766 100644 --- a/src/whatsapp/services/monitor.service.ts +++ b/src/whatsapp/services/monitor.service.ts @@ -107,6 +107,12 @@ export class WAMonitoringService { }; } + const findIntegration = await this.repository.integration.find(key); + const integration = { + ...findIntegration, + webhook_wa_business: `${urlServer}/webhook/whatsapp/${encodeURIComponent(key)}`, + }; + if (value.connectionStatus.state === 'open') { this.logger.verbose('instance: ' + key + ' - connectionStatus: open'); @@ -128,6 +134,8 @@ export class WAMonitoringService { instanceData.instance['apikey'] = (await this.repository.auth.find(key))?.apikey; instanceData.instance['chatwoot'] = chatwoot; + + instanceData.instance['integration'] = integration; } instances.push(instanceData); @@ -148,6 +156,8 @@ export class WAMonitoringService { instanceData.instance['apikey'] = (await this.repository.auth.find(key))?.apikey; instanceData.instance['chatwoot'] = chatwoot; + + instanceData.instance['integration'] = integration; } instances.push(instanceData); @@ -189,6 +199,12 @@ export class WAMonitoringService { }; } + const findIntegration = await this.repository.integration.find(key); + const integration = { + ...findIntegration, + webhook_wa_business: `${urlServer}/webhook/whatsapp/${encodeURIComponent(key)}`, + }; + if (value.connectionStatus.state === 'open') { this.logger.verbose('instance: ' + key + ' - connectionStatus: open'); @@ -210,6 +226,8 @@ export class WAMonitoringService { instanceData.instance['apikey'] = (await this.repository.auth.find(key))?.apikey; instanceData.instance['chatwoot'] = chatwoot; + + instanceData.instance['integration'] = integration; } instances.push(instanceData); @@ -230,6 +248,8 @@ export class WAMonitoringService { instanceData.instance['apikey'] = (await this.repository.auth.find(key))?.apikey; instanceData.instance['chatwoot'] = chatwoot; + + instanceData.instance['integration'] = integration; } instances.push(instanceData);