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