Adjust checklist item api to support audits trail

This commit is contained in:
Johannes Zellner
2024-06-24 18:39:37 +02:00
parent 8510b12841
commit 20396a8c7d
7 changed files with 41 additions and 16 deletions
+6 -5
View File
@@ -24,7 +24,6 @@ exports = module.exports = {
setLabel,
setTags,
setNotes,
setChecklist,
setIcon,
setTurn,
setRedis,
@@ -43,6 +42,8 @@ exports = module.exports = {
setMounts,
setUpstreamUri,
setChecklistItem,
stop,
start,
restart,
@@ -271,16 +272,16 @@ async function setNotes(req, res, next) {
next(new HttpSuccess(200, {}));
}
async function setChecklist(req, res, next) {
async function setChecklistItem(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.app, 'object');
if (typeof req.body.checklist !== 'object') return next(new HttpError(400, 'checklist must be an object'));
if (typeof req.body.done !== 'boolean') return next(new HttpError(400, 'done must be a boolean'));
const [error] = await safe(apps.setChecklist(req.app, req.body.checklist, AuditSource.fromRequest(req)));
const [error] = await safe(apps.setChecklistItem(req.app, req.params.key, req.body.done, AuditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));
next(new HttpSuccess(202, {}));
}
async function setIcon(req, res, next) {