Adjust checklist item api to support audits trail
This commit is contained in:
+14
-3
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user