mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
perf: use only required calls
This commit is contained in:
@@ -106,8 +106,14 @@ module.exports = function (privileges) {
|
||||
}
|
||||
|
||||
cids = _.uniq(cids);
|
||||
const results = await privileges.categories.getBase(privilege, cids, uid);
|
||||
return cids.filter((cid, index) => !!cid && !results.categories[index].disabled && (results.allowedTo[index] || results.isAdmin));
|
||||
const [categoryData, allowedTo, isAdmin] = await Promise.all([
|
||||
categories.getCategoriesFields(cids, ['disabled']),
|
||||
helpers.isAllowedTo(privilege, uid, cids),
|
||||
user.isAdministrator(uid),
|
||||
]);
|
||||
return cids.filter(
|
||||
(cid, index) => !!cid && !categoryData[index].disabled && (allowedTo[index] || isAdmin)
|
||||
);
|
||||
};
|
||||
|
||||
privileges.categories.getBase = async function (privilege, cids, uid) {
|
||||
|
||||
Reference in New Issue
Block a user