Skip to content

Commit 3f27d01

Browse files
Merge pull request #34 from moskoweb/groupJid-query-or-body
fix: GroupJid por Query ou por Body
2 parents d3c7677 + 6840239 commit 3f27d01

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/whatsapp/abstract/abstract.router.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,24 @@ export abstract class RouterBroker {
101101
public async groupValidate<T>(args: DataValidate<T>) {
102102
const { request, ClassRef, schema, execute } = args;
103103

104-
const groupJid = request.query as unknown as GroupJid;
105-
106-
if (!groupJid?.groupJid) {
107-
throw new BadRequestException('The group id needs to be informed in the query', 'ex: "groupJid=120362@g.us"');
108-
}
109-
110104
const instance = request.params as unknown as InstanceDto;
111105
const body = request.body;
112106

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

115-
Object.assign(body, groupJid);
116122
Object.assign(ref, body);
117123

118124
const v = validate(ref, schema);

0 commit comments

Comments
 (0)