From ce6f396bcbb0351a86b8f0d768b00e83d81e0795 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Mon, 13 Jul 2026 22:59:49 +0100 Subject: [PATCH] Audit log fixes. --- src/database/database.js | 8 ++++---- src/utils.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/database/database.js b/src/database/database.js index 292bef6..04dfde9 100644 --- a/src/database/database.js +++ b/src/database/database.js @@ -833,7 +833,7 @@ export const editObject = async ({ model, id, updateData, user, populate, recalc // Audit log before update await editAuditLog( previousExpandedObject, - { ...previousExpandedObject, ...updateData }, + { ...previousExpandedObject, ...expandObjectIds(updateData) }, id, parentType, user @@ -846,7 +846,7 @@ export const editObject = async ({ model, id, updateData, user, populate, recalc ) { await editNotification( previousExpandedObject, - { ...previousExpandedObject, ...updateData }, + { ...previousExpandedObject, ...expandObjectIds(updateData) }, id, parentType, user @@ -857,11 +857,11 @@ export const editObject = async ({ model, id, updateData, user, populate, recalc // Call childUpdate event for any child objects await distributeChildUpdate( previousExpandedObject, - { ...previousExpandedObject, ...updateData }, + { ...previousExpandedObject, ...expandObjectIds(updateData) }, id, model ); - const updatedObject = { ...previousExpandedObject, ...updateData }; + const updatedObject = { ...previousExpandedObject, ...expandObjectIds(updateData) }; // Update cache with the new version await updateObjectCache({ diff --git a/src/utils.js b/src/utils.js index d537e3a..523600a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -667,7 +667,7 @@ async function newAuditLog(newValue, parentId, parentType, user) { await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); } async function editAuditLog(oldValue, newValue, parentId, parentType, user) { @@ -698,7 +698,7 @@ async function editAuditLog(oldValue, newValue, parentId, parentType, user) { await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); } async function editNotification(oldValue, newValue, parentId, parentType, user) { @@ -747,7 +747,7 @@ async function deleteAuditLog(deleteValue, parentId, parentType, user) { await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); } async function deleteNotification(object, parentId, parentType, user) { @@ -799,7 +799,7 @@ async function subscribeAuditLog(parentId, parentType, user) { operation: 'subscribe', }); await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); return auditLog; } @@ -812,7 +812,7 @@ async function unsubscribeAuditLog(parentId, parentType, user) { operation: 'unsubscribe', }); await auditLog.save(); - await distributeNew(auditLog._id, 'auditLog'); + await distributeNew(auditLog, 'auditLog'); return auditLog; }