Audit log fixes.
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good

This commit is contained in:
Tom Butcher 2026-07-13 22:59:49 +01:00
parent bf3e23ddf1
commit ce6f396bcb
2 changed files with 9 additions and 9 deletions

View File

@ -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({

View File

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