Skip to content

Commit

Permalink
chore: update permissions for get module
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Dec 4, 2024
1 parent 8ab2d82 commit 936c144
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/controllers/community.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion src/routes/v1/module.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 1 addition & 12 deletions src/services/module.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,12 @@ const deleteModule = async (module: HydratedDocument<IModule>): Promise<Hydrated
interface communityWithModules extends IModule {
modules: string[];
}
/**
* Populate modules
* @param {HydratedDocument<ICommunity>} 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,
getModuleByFilter,
getModuleById,
deleteModule,
updateModule,
getActiveModulesForCommunity,
};

0 comments on commit 936c144

Please sign in to comment.