Skip to content

Commit

Permalink
feat: Added '/common-groups' router
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Nov 15, 2023
1 parent 004fbbb commit ad52159
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/controller/groupController.ts
Expand Up @@ -1046,3 +1046,30 @@ export async function setGroupProfilePic(req: Request, res: Response) {
});
}
}

export async function getCommonGroups(req: Request, res: Response) {
/**
#swagger.tags = ["Group"]
#swagger.autoBody=false
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters["session"] = {
schema: 'NERDWHATS_AMERICA'
}
#swagger.parameters["wid"] = {
schema: '5521999999999@c.us'
}
*/
const { wid } = req.params;
try {
return res.status(200).json(await (req.client as any).getCommonGroups(wid));
} catch (e) {
req.logger.error(e);
return res.status(500).json({
status: 'error',
message: 'Error on get common groups',
error: e,
});
}
}
6 changes: 6 additions & 0 deletions src/routes/index.ts
Expand Up @@ -233,6 +233,12 @@ routes.get(
statusConnection,
GroupController.getGroupMembers
);
routes.get(
'/api/:session/common-groups/:wid',
verifyToken,
statusConnection,
GroupController.getCommonGroups
);
routes.get(
'/api/:session/group-admins/:groupId',
verifyToken,
Expand Down
47 changes: 47 additions & 0 deletions src/swagger.json
Expand Up @@ -1655,6 +1655,14 @@
"example": "<groupId>"
},
"in": "query"
},
{
"name": "wid",
"schema": {
"type": "string",
"example": "5521999999999@c.us"
},
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -1755,6 +1763,45 @@
}
}
},
"/api/{session}/common-groups/{wid}": {
"get": {
"tags": ["Group"],
"description": "",
"parameters": [
{
"name": "session",
"in": "path",
"required": true,
"schema": {
"type": "string",
"example": "NERDWHATS_AMERICA"
}
},
{
"name": "wid",
"in": "path",
"required": true,
"schema": {
"type": "string",
"example": "5521999999999@c.us"
}
}
],
"responses": {
"200": {
"description": "OK"
},
"500": {
"description": "Internal Server Error"
}
},
"security": [
{
"bearerAuth": []
}
]
}
},
"/api/{session}/group-admins/{groupId}": {
"get": {
"tags": ["Group"],
Expand Down

0 comments on commit ad52159

Please sign in to comment.