mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 12:36:02 +01:00
refactor(socket.io): deprecate categories.get in favour of api.categories.list
This commit is contained in:
@@ -15,6 +15,22 @@ const hasAdminPrivilege = async (uid, privilege = 'categories') => {
|
||||
}
|
||||
};
|
||||
|
||||
categoriesAPI.list = async (caller) => {
|
||||
async function getCategories() {
|
||||
const cids = await categories.getCidsByPrivilege('categories:cid', caller.uid, 'find');
|
||||
return await categories.getCategoriesData(cids);
|
||||
}
|
||||
|
||||
const [isAdmin, categoriesData] = await Promise.all([
|
||||
user.isAdministrator(caller.uid),
|
||||
getCategories(),
|
||||
]);
|
||||
|
||||
return {
|
||||
categories: categoriesData.filter(category => category && (!category.disabled || isAdmin)),
|
||||
};
|
||||
};
|
||||
|
||||
categoriesAPI.get = async function (caller, data) {
|
||||
const [userPrivileges, category] = await Promise.all([
|
||||
privileges.categories.get(data.cid, caller.uid),
|
||||
|
||||
Reference in New Issue
Block a user