From 04b9a070c43a5974e84d7aee50c01f1bc7083c99 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Fri, 18 Aug 2023 12:46:46 -0300 Subject: [PATCH] Added send and date_time in webhook data --- src/whatsapp/services/whatsapp.service.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index 49f51c44..d11946ee 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -587,6 +587,9 @@ export class WAStartupService { const serverUrl = this.configService.get('SERVER').URL; const we = event.replace(/[.-]/gm, '_').toUpperCase(); const transformedWe = we.replace(/_/gm, '-').toLowerCase(); + const tzoffset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds + const localISOTime = new Date(Date.now() - tzoffset).toISOString(); + const now = localISOTime; const expose = this.configService.get('AUTHENTICATION').EXPOSE_IN_FETCH_INSTANCES; const tokenStore = await this.repository.auth.find(this.instanceName); @@ -621,6 +624,8 @@ export class WAStartupService { instance: this.instance.name, data, server_url: serverUrl, + date_time: now, + sender: this.wuid, }; if (expose && instanceApikey) { @@ -643,6 +648,8 @@ export class WAStartupService { instance: this.instance.name, data, server_url: serverUrl, + date_time: now, + sender: this.wuid, }; if (expose && instanceApikey) { @@ -675,7 +682,7 @@ export class WAStartupService { instance: this.instance.name, data, destination: this.localWebhook.url, - ISODatetime: new Date().toISOString(), + date_time: now, sender: this.wuid, server_url: serverUrl, apikey: (expose && instanceApikey) || null, @@ -696,6 +703,7 @@ export class WAStartupService { instance: this.instance.name, data, destination: this.localWebhook.url, + date_time: now, sender: this.wuid, server_url: serverUrl, }; @@ -746,6 +754,7 @@ export class WAStartupService { instance: this.instance.name, data, destination: localUrl, + date_time: now, sender: this.wuid, server_url: serverUrl, }; @@ -765,6 +774,7 @@ export class WAStartupService { instance: this.instance.name, data, destination: localUrl, + date_time: now, sender: this.wuid, server_url: serverUrl, };