diff --git a/src/whatsapp/abstract/abstract.router.ts b/src/whatsapp/abstract/abstract.router.ts index bf1eee1b..136b946a 100644 --- a/src/whatsapp/abstract/abstract.router.ts +++ b/src/whatsapp/abstract/abstract.router.ts @@ -104,16 +104,24 @@ export abstract class RouterBroker { const instance = request.params as unknown as InstanceDto; const body = request.body; - if (!body?.groupJid) { - if (request.query.groupJid) { - Object.assign(body, { - groupJid: request.query.groupJid, - }); + let groupJid = body?.groupJid; + + if (!groupJid) { + if (request.query?.groupJid) { + groupJid = request.query.groupJid; } else { throw new BadRequestException('The group id needs to be informed in the query', 'ex: "groupJid=120362@g.us"'); } } - + + if (!groupJid.endsWith('@g.us')) { + groupJid = groupJid + '@g.us'; + } + + Object.assign(body, { + groupJid: groupJid + }); + const ref = new ClassRef(); Object.assign(ref, body); diff --git a/src/whatsapp/controllers/instance.controller.ts b/src/whatsapp/controllers/instance.controller.ts index e45644fe..64867a2d 100644 --- a/src/whatsapp/controllers/instance.controller.ts +++ b/src/whatsapp/controllers/instance.controller.ts @@ -55,19 +55,12 @@ export class InstanceController { try { 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'); - } - this.logger.verbose('checking duplicate token'); await this.authService.checkDuplicateToken(token); this.logger.verbose('creating instance'); const instance = new WAStartupService(this.configService, this.eventEmitter, this.repository, this.cache); - instance.instanceName = instanceName - .toLowerCase() - .replace(/[^a-z0-9]/g, '') - .replace(' ', ''); + instance.instanceName = instanceName; this.logger.verbose('instance: ' + instance.instanceName + ' created');