From d7f264c1c2265d145b0ca0542cd1984600974080 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Fri, 21 Jul 2023 12:26:43 -0300 Subject: [PATCH] fix: It is now validated if the instance name contains uppercase and special characters --- CHANGELOG.md | 1 + src/whatsapp/controllers/instance.controller.ts | 6 ++++++ src/whatsapp/services/whatsapp.service.ts | 2 -- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2311edac..d9b5ac6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Correction in the use of the api with mongodb * Adjustments to search endpoint for contacts, chats, messages and Status messages * Now when deleting the instance, the data referring to it in mongodb is also deleted +* It is now validated if the instance name contains uppercase and special characters # 1.3.1 (2023-07-20 07:48) diff --git a/src/whatsapp/controllers/instance.controller.ts b/src/whatsapp/controllers/instance.controller.ts index f0adb3a3..ef0c00aa 100644 --- a/src/whatsapp/controllers/instance.controller.ts +++ b/src/whatsapp/controllers/instance.controller.ts @@ -42,6 +42,12 @@ export class InstanceController { }: InstanceDto) { this.logger.verbose('requested createInstance from ' + instanceName + ' instance'); + if (instanceName !== instanceName.toLowerCase().replace(/[^a-z0-9]/g, '')) { + throw new BadRequestException( + 'The instance name must be lowercase and without special characters', + ); + } + const mode = this.configService.get('AUTHENTICATION').INSTANCE.MODE; if (mode === 'container') { diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index 8035bbfb..549dd7d6 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -1412,8 +1412,6 @@ export class WAStartupService { } if (Number(countryCode) === 52 || Number(countryCode) === 54) { - console.log('numero mexicano'); - const formattedMXARNumber = this.formatMXOrARNumber(number); if (formattedMXARNumber !== number) {