diff --git a/src/controller/groupController.ts b/src/controller/groupController.ts index c527e54b5..71ba99698 100644 --- a/src/controller/groupController.ts +++ b/src/controller/groupController.ts @@ -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, + }); + } +} diff --git a/src/routes/index.ts b/src/routes/index.ts index d738619ce..bf086ea03 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -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, diff --git a/src/swagger.json b/src/swagger.json index a4fb42310..bf99e88ba 100644 --- a/src/swagger.json +++ b/src/swagger.json @@ -1655,6 +1655,14 @@ "example": "" }, "in": "query" + }, + { + "name": "wid", + "schema": { + "type": "string", + "example": "5521999999999@c.us" + }, + "in": "query" } ], "responses": { @@ -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"],