@@ -200,6 +200,7 @@ export class WAStartupService {
200200 const data = await this . repository . webhook . find ( this . instanceName ) ;
201201 this . localWebhook . url = data ?. url ;
202202 this . localWebhook . enabled = data ?. enabled ;
203+ this . localWebhook . events = data ?. events ;
203204 }
204205
205206 public async setWebhook ( data : WebhookRaw ) {
@@ -212,12 +213,13 @@ export class WAStartupService {
212213 }
213214
214215 public async sendDataWebhook < T = any > ( event : Events , data : T , local = true ) {
215- const webhook = this . configService . get < Webhook > ( 'WEBHOOK' ) ;
216+ const webhookGlobal = this . configService . get < Webhook > ( 'WEBHOOK' ) ;
217+ const webhookLocal = this . localWebhook . events ;
216218 const we = event . replace ( / [ \. - ] / gm, '_' ) . toUpperCase ( ) ;
217219 const transformedWe = we . replace ( / _ / gm, '-' ) . toLowerCase ( ) ;
218220 const instance = this . configService . get < Auth > ( 'AUTHENTICATION' ) . INSTANCE ;
219221
220- if ( webhook . EVENTS [ we ] ) {
222+ if ( Array . isArray ( webhookLocal ) && webhookLocal . includes ( we ) ) {
221223 if ( local && instance . MODE !== 'container' ) {
222224 const { WEBHOOK_BY_EVENTS } = instance ;
223225
@@ -229,6 +231,15 @@ export class WAStartupService {
229231 baseURL = this . localWebhook . url ;
230232 }
231233
234+ this . logger . log ( {
235+ local : WAStartupService . name + '.sendDataWebhook-local' ,
236+ url : baseURL ,
237+ event,
238+ instance : this . instance . name ,
239+ data,
240+ destination : this . localWebhook . url ,
241+ } ) ;
242+
232243 try {
233244 if ( this . localWebhook . enabled && isURL ( this . localWebhook . url ) ) {
234245 const httpService = axios . create ( { baseURL } ) ;
@@ -253,12 +264,13 @@ export class WAStartupService {
253264 } ) ;
254265 }
255266 }
256-
267+ }
268+ if ( webhookGlobal . EVENTS [ we ] ) {
257269 const globalWebhook = this . configService . get < Webhook > ( 'WEBHOOK' ) . GLOBAL ;
258270
259271 let globalURL ;
260272
261- if ( webhook . GLOBAL . WEBHOOK_BY_EVENTS ) {
273+ if ( webhookGlobal . GLOBAL . WEBHOOK_BY_EVENTS ) {
262274 globalURL = `${ globalWebhook . URL } /${ transformedWe } ` ;
263275 } else {
264276 globalURL = globalWebhook . URL ;
@@ -273,6 +285,7 @@ export class WAStartupService {
273285 }
274286
275287 this . logger . log ( {
288+ local : WAStartupService . name + '.sendDataWebhook-global' ,
276289 url : globalURL ,
277290 event,
278291 instance : this . instance . name ,
0 commit comments