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
+14 -3
View File
@@ -32,7 +32,7 @@ exports = module.exports = {
setIcon,
setTags,
setNotes,
setChecklist,
setChecklistItem,
setMemoryLimit,
setCpuQuota,
setMounts,
@@ -1550,11 +1550,22 @@ async function setNotes(app, notes, auditSource) {
await eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId: app.id, app, notes });
}
async function setChecklist(app, checklist, auditSource) {
async function setChecklistItem(app, checklistItemKey, acknowledged, auditSource) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof checklist, 'object');
assert.strictEqual(typeof checklistItemKey, 'string');
assert.strictEqual(typeof acknowledged, 'boolean');
assert.strictEqual(typeof auditSource, 'object');
if (!app.checklist[checklistItemKey]) throw new BoxError(BoxError.NOT_FOUND, 'no such checklist item');
// nothing changed
if (app.checklist[checklistItemKey].acknowledged === acknowledged) return;
const checklist = app.checklist;
checklist[checklistItemKey].acknowledged = acknowledged;
checklist[checklistItemKey].changedAt = Date.now();
checklist[checklistItemKey].changedBy = auditSource.username;
await update(app.id, { checklist });
await eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId: app.id, app, checklist });
}