Skip to content

Commit 27aa0ad

Browse files
committed
fix: Adjusted set in webhook to go empty when enabled false
1 parent 24712c4 commit 27aa0ad

6 files changed

Lines changed: 20 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
### Features
44

5-
* Route to send status broadcast
5+
* Route to send status broadcast¼
6+
7+
### Fixed
8+
9+
* Adjusted set in webhook to go empty when enabled false
610

711
# 1.1.3 (2023-07-06 11:43)
812

Docker/redis/docker-compose.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ networks:
77
services:
88
redis:
99
image: redis:latest
10-
command: >
11-
redis-server
12-
--port 6379
13-
--appendonly yes
14-
--save 900 1
15-
--save 300 10
16-
--save 60 10000
17-
--appendfsync everysec
18-
volumes:
19-
- evolution_redis:/data
2010
container_name: redis
2111
ports:
2212
- 6379:6379

src/db/redis.client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ export class RedisCache {
104104
public async delAll(hash?: string) {
105105
try {
106106
this.logger.verbose('instance delAll: ' + hash);
107-
return await this.client.del(
107+
const result = await this.client.del(
108108
hash || this.redisEnv.PREFIX_KEY + ':' + this.instanceName,
109109
);
110+
111+
return result;
110112
} catch (error) {
111113
this.logger.error(error);
112114
}

src/validate/validate.schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const instanceNameSchema: JSONSchema7 = {
3030
webhook_by_events: { type: 'boolean' },
3131
events: {
3232
type: 'array',
33-
minItems: 1,
33+
minItems: 0,
3434
items: {
3535
type: 'string',
3636
enum: [
@@ -825,7 +825,7 @@ export const webhookSchema: JSONSchema7 = {
825825
enabled: { type: 'boolean', enum: [true, false] },
826826
events: {
827827
type: 'array',
828-
minItems: 1,
828+
minItems: 0,
829829
items: {
830830
type: 'string',
831831
enum: [

src/whatsapp/controllers/webhook.controller.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ export class WebhookController {
88
constructor(private readonly webhookService: WebhookService) {}
99

1010
public async createWebhook(instance: InstanceDto, data: WebhookDto) {
11-
if (!isURL(data.url, { require_tld: false })) {
11+
if (data.enabled && !isURL(data.url, { require_tld: false })) {
1212
throw new BadRequestException('Invalid "url" property');
1313
}
14+
15+
if (!data.enabled) {
16+
data.url = '';
17+
data.events = [];
18+
}
19+
1420
return this.webhookService.create(instance, data);
1521
}
1622

src/whatsapp/services/monitor.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ export class WAMonitoringService {
216216
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
217217
}
218218

219+
public async clearStoreFiles(instanceName: string) {}
220+
219221
public async loadInstance() {
220222
this.logger.verbose('load instances');
221223
const set = async (name: string) => {
@@ -300,6 +302,7 @@ export class WAMonitoringService {
300302
try {
301303
this.logger.verbose('request cleaning up instance: ' + instanceName);
302304
this.cleaningUp(instanceName);
305+
this.clearStoreFiles(instanceName);
303306
} finally {
304307
this.logger.warn(`Instance "${instanceName}" - REMOVED`);
305308
}

0 commit comments

Comments
 (0)