Skip to content

Commit 04b9a07

Browse files
committed
Added send and date_time in webhook data
1 parent dd2caf7 commit 04b9a07

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/whatsapp/services/whatsapp.service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ export class WAStartupService {
587587
const serverUrl = this.configService.get<HttpServer>('SERVER').URL;
588588
const we = event.replace(/[.-]/gm, '_').toUpperCase();
589589
const transformedWe = we.replace(/_/gm, '-').toLowerCase();
590+
const tzoffset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds
591+
const localISOTime = new Date(Date.now() - tzoffset).toISOString();
592+
const now = localISOTime;
590593

591594
const expose = this.configService.get<Auth>('AUTHENTICATION').EXPOSE_IN_FETCH_INSTANCES;
592595
const tokenStore = await this.repository.auth.find(this.instanceName);
@@ -621,6 +624,8 @@ export class WAStartupService {
621624
instance: this.instance.name,
622625
data,
623626
server_url: serverUrl,
627+
date_time: now,
628+
sender: this.wuid,
624629
};
625630

626631
if (expose && instanceApikey) {
@@ -643,6 +648,8 @@ export class WAStartupService {
643648
instance: this.instance.name,
644649
data,
645650
server_url: serverUrl,
651+
date_time: now,
652+
sender: this.wuid,
646653
};
647654

648655
if (expose && instanceApikey) {
@@ -675,7 +682,7 @@ export class WAStartupService {
675682
instance: this.instance.name,
676683
data,
677684
destination: this.localWebhook.url,
678-
ISODatetime: new Date().toISOString(),
685+
date_time: now,
679686
sender: this.wuid,
680687
server_url: serverUrl,
681688
apikey: (expose && instanceApikey) || null,
@@ -696,6 +703,7 @@ export class WAStartupService {
696703
instance: this.instance.name,
697704
data,
698705
destination: this.localWebhook.url,
706+
date_time: now,
699707
sender: this.wuid,
700708
server_url: serverUrl,
701709
};
@@ -746,6 +754,7 @@ export class WAStartupService {
746754
instance: this.instance.name,
747755
data,
748756
destination: localUrl,
757+
date_time: now,
749758
sender: this.wuid,
750759
server_url: serverUrl,
751760
};
@@ -765,6 +774,7 @@ export class WAStartupService {
765774
instance: this.instance.name,
766775
data,
767776
destination: localUrl,
777+
date_time: now,
768778
sender: this.wuid,
769779
server_url: serverUrl,
770780
};

0 commit comments

Comments
 (0)