From e7ed66603794a2542a3d38eb0f3631da6fb912d2 Mon Sep 17 00:00:00 2001 From: Alan Mosko Date: Wed, 26 Jul 2023 17:27:25 -0300 Subject: [PATCH 1/2] Update abstract.router.ts --- src/whatsapp/abstract/abstract.router.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/whatsapp/abstract/abstract.router.ts b/src/whatsapp/abstract/abstract.router.ts index cb224cd6..c44c6880 100644 --- a/src/whatsapp/abstract/abstract.router.ts +++ b/src/whatsapp/abstract/abstract.router.ts @@ -98,22 +98,24 @@ export abstract class RouterBroker { public async groupValidate(args: DataValidate) { const { request, ClassRef, schema, execute } = args; - - const groupJid = request.query as unknown as GroupJid; - - if (!groupJid?.groupJid) { - throw new BadRequestException( - 'The group id needs to be informed in the query', - 'ex: "groupJid=120362@g.us"', - ); - } - 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 + }); + } else { + throw new BadRequestException( + 'The group id needs to be informed in the query', + 'ex: "groupJid=120362@g.us"', + ); + } + } + const ref = new ClassRef(); - Object.assign(body, groupJid); Object.assign(ref, body); const v = validate(ref, schema); From af5746bb39054bb1c75b5dacf2238efc245aa239 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Wed, 26 Jul 2023 17:45:28 -0300 Subject: [PATCH 2/2] Revert "GroupJid por Query ou por Body" --- src/whatsapp/abstract/abstract.router.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/whatsapp/abstract/abstract.router.ts b/src/whatsapp/abstract/abstract.router.ts index d18cf36d..3c19e6bb 100644 --- a/src/whatsapp/abstract/abstract.router.ts +++ b/src/whatsapp/abstract/abstract.router.ts @@ -101,24 +101,18 @@ export abstract class RouterBroker { public async groupValidate(args: DataValidate) { const { request, ClassRef, schema, execute } = args; + const groupJid = request.query as unknown as GroupJid; + + if (!groupJid?.groupJid) { + throw new BadRequestException('The group id needs to be informed in the query', 'ex: "groupJid=120362@g.us"'); + } + 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 - }); - } else { - throw new BadRequestException( - 'The group id needs to be informed in the query', - 'ex: "groupJid=120362@g.us"', - ); - } - } - const ref = new ClassRef(); + Object.assign(body, groupJid); Object.assign(ref, body); const v = validate(ref, schema);