feat(api): #9123, migrate rest of the getObject controllers to Write API

This commit is contained in:
Julian Lam
2020-12-28 19:52:46 -05:00
parent cdff8d286a
commit 9ecfac9b68
5 changed files with 35 additions and 29 deletions

View File

@@ -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);