mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
feat(api): #9123, migrate rest of the getObject controllers to Write API
This commit is contained in:
@@ -2,9 +2,22 @@
|
||||
|
||||
const categories = require('../categories');
|
||||
const events = require('../events');
|
||||
const privileges = require('../privileges');
|
||||
|
||||
const categoriesAPI = module.exports;
|
||||
|
||||
categoriesAPI.get = async function (caller, data) {
|
||||
const [userPrivileges, category] = await Promise.all([
|
||||
privileges.categories.get(data.cid, caller.uid),
|
||||
categories.getCategoryData(data.cid),
|
||||
]);
|
||||
if (!category || !userPrivileges.read) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return category;
|
||||
};
|
||||
|
||||
categoriesAPI.create = async function (caller, data) {
|
||||
const response = await categories.create(data);
|
||||
const categoryObjs = await categories.getCategories([response.cid], caller.uid);
|
||||
|
||||
Reference in New Issue
Block a user