Skip to content

Commit f2d0a8e

Browse files
committed
fixed the problem of not disabling the global webhook by the variable and apikey only appears if it is enabled to be exposed
1 parent 9201bc1 commit f2d0a8e

4 files changed

Lines changed: 97 additions & 85 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Adjust the route getProfileBusiness to fetchProfileBusiness
2121
* fix error after logout and try to get status or to connect again
2222
* fix sending narrated audio on whatsapp android and ios
23+
* fixed the problem of not disabling the global webhook by the variable
2324

2425
# 1.0.9 (2023-06-10)
2526

docker-compose.yaml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ services:
1111
context: .
1212
dockerfile: Dockerfile
1313
ports:
14-
- 8080:8080
15-
volumes:
16-
- /data/instances:/evolution/instances
14+
- 8083:8080
15+
# volumes:
16+
# - /data/instances:/evolution/instances
1717
environment:
1818
# Determine how long the instance should be deleted from memory in case of no connection.
1919
# Default time: 5 minutes
@@ -25,7 +25,7 @@ services:
2525
- STORE_CONTACTS=true
2626
- STORE_CHATS=true
2727
# Permanent data storage
28-
- DATABASE_ENABLED=true
28+
- DATABASE_ENABLED=false
2929
- DATABASE_CONNECTION_URI=mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true
3030
- DATABASE_CONNECTION_DB_PREFIX_NAME=evolution
3131
# Choose the data you want to save in the application's database or store
@@ -35,7 +35,7 @@ services:
3535
- DATABASE_SAVE_MESSAGE_UPDATE=false
3636
- DATABASE_SAVE_DATA_CONTACTS=true
3737
- DATABASE_SAVE_DATA_CHATS=true
38-
- REDIS_ENABLED=true
38+
- REDIS_ENABLED=false
3939
- REDIS_URI=redis://redis:6379
4040
- REDIS_PREFIX_KEY=evolution
4141
# Webhook Settings
@@ -92,31 +92,31 @@ services:
9292
expose:
9393
- 8083
9494

95-
mongodb:
96-
container_name: mongodb
97-
image: mongo
98-
restart: always
99-
volumes:
100-
- /data/mongodb:/data/db
101-
ports:
102-
- 27017:27017
103-
environment:
104-
MONGO_INITDB_ROOT_USERNAME: root
105-
MONGO_INITDB_ROOT_PASSWORD: root
106-
networks:
107-
- evolution-net
108-
expose:
109-
- 27017
95+
# mongodb:
96+
# container_name: mongodb
97+
# image: mongo
98+
# restart: always
99+
# volumes:
100+
# - /data/mongodb:/data/db
101+
# ports:
102+
# - 27017:27017
103+
# environment:
104+
# MONGO_INITDB_ROOT_USERNAME: root
105+
# MONGO_INITDB_ROOT_PASSWORD: root
106+
# networks:
107+
# - evolution-net
108+
# expose:
109+
# - 27017
110110

111-
redis:
112-
container_name: redis
113-
image: redis:latest
114-
restart: always
115-
volumes:
116-
- /data/redis:/data
117-
ports:
118-
- 6379:6379
119-
networks:
120-
- evolution-net
121-
expose:
122-
- 6379
111+
# redis:
112+
# container_name: redis
113+
# image: redis:latest
114+
# restart: always
115+
# volumes:
116+
# - /data/redis:/data
117+
# ports:
118+
# - 6379:6379
119+
# networks:
120+
# - evolution-net
121+
# expose:
122+
# - 6379

src/whatsapp/services/monitor.service.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,28 @@ export class WAMonitoringService {
7272
if (this.configService.get<Auth>('AUTHENTICATION').EXPOSE_IN_FETCH_INSTANCES) {
7373
const tokenStore = await this.repository.auth.find(key);
7474
apikey = tokenStore.apikey || '';
75+
76+
instances.push({
77+
instance: {
78+
instanceName: key,
79+
owner: value.wuid,
80+
profileName: (await value.getProfileName()) || 'not loaded',
81+
profilePictureUrl: value.profilePictureUrl,
82+
status: (await value.getProfileStatus()) || '',
83+
apikey,
84+
},
85+
});
7586
} else {
76-
apikey = '';
87+
instances.push({
88+
instance: {
89+
instanceName: key,
90+
owner: value.wuid,
91+
profileName: (await value.getProfileName()) || 'not loaded',
92+
profilePictureUrl: value.profilePictureUrl,
93+
status: (await value.getProfileStatus()) || '',
94+
},
95+
});
7796
}
78-
79-
instances.push({
80-
instance: {
81-
instanceName: key,
82-
owner: value.wuid,
83-
profileName: (await value.getProfileName()) || 'not loaded',
84-
profilePictureUrl: value.profilePictureUrl,
85-
status: (await value.getProfileStatus()) || '',
86-
apikey,
87-
},
88-
});
8997
} else {
9098
instances.push({
9199
instance: {

src/whatsapp/services/whatsapp.service.ts

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -265,56 +265,59 @@ export class WAStartupService {
265265
}
266266
}
267267
}
268-
if (webhookGlobal.EVENTS[we]) {
269-
const globalWebhook = this.configService.get<Webhook>('WEBHOOK').GLOBAL;
270268

271-
let globalURL;
269+
if (webhookGlobal.GLOBAL?.ENABLED) {
270+
if (webhookGlobal.EVENTS[we]) {
271+
const globalWebhook = this.configService.get<Webhook>('WEBHOOK').GLOBAL;
272272

273-
if (webhookGlobal.GLOBAL.WEBHOOK_BY_EVENTS) {
274-
globalURL = `${globalWebhook.URL}/${transformedWe}`;
275-
} else {
276-
globalURL = globalWebhook.URL;
277-
}
278-
279-
let localUrl;
273+
let globalURL;
280274

281-
if (instance.MODE === 'container') {
282-
localUrl = instance.WEBHOOK_URL;
283-
} else {
284-
localUrl = this.localWebhook.url;
285-
}
275+
if (webhookGlobal.GLOBAL.WEBHOOK_BY_EVENTS) {
276+
globalURL = `${globalWebhook.URL}/${transformedWe}`;
277+
} else {
278+
globalURL = globalWebhook.URL;
279+
}
286280

287-
this.logger.log({
288-
local: WAStartupService.name + '.sendDataWebhook-global',
289-
url: globalURL,
290-
event,
291-
instance: this.instance.name,
292-
data,
293-
destination: localUrl,
294-
});
281+
let localUrl;
295282

296-
try {
297-
if (globalWebhook && globalWebhook?.ENABLED && isURL(globalURL)) {
298-
const httpService = axios.create({ baseURL: globalURL });
299-
await httpService.post('', {
300-
event,
301-
instance: this.instance.name,
302-
data,
303-
destination: localUrl,
304-
});
283+
if (instance.MODE === 'container') {
284+
localUrl = instance.WEBHOOK_URL;
285+
} else {
286+
localUrl = this.localWebhook.url;
305287
}
306-
} catch (error) {
307-
this.logger.error({
288+
289+
this.logger.log({
308290
local: WAStartupService.name + '.sendDataWebhook-global',
309-
message: error?.message,
310-
hostName: error?.hostname,
311-
syscall: error?.syscall,
312-
code: error?.code,
313-
error: error?.errno,
314-
stack: error?.stack,
315-
name: error?.name,
316291
url: globalURL,
292+
event,
293+
instance: this.instance.name,
294+
data,
295+
destination: localUrl,
317296
});
297+
298+
try {
299+
if (globalWebhook && globalWebhook?.ENABLED && isURL(globalURL)) {
300+
const httpService = axios.create({ baseURL: globalURL });
301+
await httpService.post('', {
302+
event,
303+
instance: this.instance.name,
304+
data,
305+
destination: localUrl,
306+
});
307+
}
308+
} catch (error) {
309+
this.logger.error({
310+
local: WAStartupService.name + '.sendDataWebhook-global',
311+
message: error?.message,
312+
hostName: error?.hostname,
313+
syscall: error?.syscall,
314+
code: error?.code,
315+
error: error?.errno,
316+
stack: error?.stack,
317+
name: error?.name,
318+
url: globalURL,
319+
});
320+
}
318321
}
319322
}
320323
}

0 commit comments

Comments
 (0)