From 936c14431e5b696d874978db409abc7c0f565529 Mon Sep 17 00:00:00 2001 From: Behzad Rabiei Date: Wed, 4 Dec 2024 15:40:38 +0200 Subject: [PATCH] chore: update permissions for get module --- src/controllers/community.controller.ts | 1 - src/routes/v1/module.route.ts | 2 +- src/services/module.service.ts | 13 +------------ 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/controllers/community.controller.ts b/src/controllers/community.controller.ts index 60bcc97..4901e1c 100644 --- a/src/controllers/community.controller.ts +++ b/src/controllers/community.controller.ts @@ -40,7 +40,6 @@ const getCommunity = catchAsync(async function (req: IAuthRequest, res: Response select: '_id name metadata disconnectedAt', }); community = await communityService.populateRoles(community); - community = await moduleService.getActiveModulesForCommunity(community); } res.send(community); }); diff --git a/src/routes/v1/module.route.ts b/src/routes/v1/module.route.ts index 39244d0..18ed4ca 100644 --- a/src/routes/v1/module.route.ts +++ b/src/routes/v1/module.route.ts @@ -13,7 +13,7 @@ router router .route('/:moduleId') - .get(auth('admin'), validate(moduleValidation.getModule), moduleController.getModule) + .get(auth('admin', 'view'), validate(moduleValidation.getModule), moduleController.getModule) .patch(auth('admin'), validate(moduleValidation.dynamicModuleUpdate), moduleController.updateModule) .delete(auth('admin'), validate(moduleValidation.deleteModule), moduleController.deleteModule); diff --git a/src/services/module.service.ts b/src/services/module.service.ts index d3eeda2..d056f2a 100644 --- a/src/services/module.service.ts +++ b/src/services/module.service.ts @@ -97,17 +97,7 @@ const deleteModule = async (module: HydratedDocument): Promise} community - */ -const getActiveModulesForCommunity = async (community: any) => { - const modules = await getModulesByFilter({ community: community.id }); - const moduleNames = [...new Set(modules.map((module) => module.name))]; - const communityObj = community.toObject(); - communityObj.modules = moduleNames; - return communityObj; -}; + export default { createModule, queryModules, @@ -115,5 +105,4 @@ export default { getModuleById, deleteModule, updateModule, - getActiveModulesForCommunity, };