Skip to content

Commit e7ed666

Browse files
committed
Update abstract.router.ts
1 parent fb6e58b commit e7ed666

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

src/whatsapp/abstract/abstract.router.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,24 @@ export abstract class RouterBroker {
9898

9999
public async groupValidate<T>(args: DataValidate<T>) {
100100
const { request, ClassRef, schema, execute } = args;
101-
102-
const groupJid = request.query as unknown as GroupJid;
103-
104-
if (!groupJid?.groupJid) {
105-
throw new BadRequestException(
106-
'The group id needs to be informed in the query',
107-
'ex: "groupJid=120362@g.us"',
108-
);
109-
}
110-
111101
const instance = request.params as unknown as InstanceDto;
112102
const body = request.body;
113103

104+
if (!body?.groupJid) {
105+
if (request.query.groupJid) {
106+
Object.assign(body, {
107+
groupJid: request.query.groupJid
108+
});
109+
} else {
110+
throw new BadRequestException(
111+
'The group id needs to be informed in the query',
112+
'ex: "groupJid=120362@g.us"',
113+
);
114+
}
115+
}
116+
114117
const ref = new ClassRef();
115118

116-
Object.assign(body, groupJid);
117119
Object.assign(ref, body);
118120

119121
const v = validate(ref, schema);

0 commit comments

Comments
 (0)