Audit log fixes.
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This commit is contained in:
parent
bf3e23ddf1
commit
ce6f396bcb
@ -833,7 +833,7 @@ export const editObject = async ({ model, id, updateData, user, populate, recalc
|
|||||||
// Audit log before update
|
// Audit log before update
|
||||||
await editAuditLog(
|
await editAuditLog(
|
||||||
previousExpandedObject,
|
previousExpandedObject,
|
||||||
{ ...previousExpandedObject, ...updateData },
|
{ ...previousExpandedObject, ...expandObjectIds(updateData) },
|
||||||
id,
|
id,
|
||||||
parentType,
|
parentType,
|
||||||
user
|
user
|
||||||
@ -846,7 +846,7 @@ export const editObject = async ({ model, id, updateData, user, populate, recalc
|
|||||||
) {
|
) {
|
||||||
await editNotification(
|
await editNotification(
|
||||||
previousExpandedObject,
|
previousExpandedObject,
|
||||||
{ ...previousExpandedObject, ...updateData },
|
{ ...previousExpandedObject, ...expandObjectIds(updateData) },
|
||||||
id,
|
id,
|
||||||
parentType,
|
parentType,
|
||||||
user
|
user
|
||||||
@ -857,11 +857,11 @@ export const editObject = async ({ model, id, updateData, user, populate, recalc
|
|||||||
// Call childUpdate event for any child objects
|
// Call childUpdate event for any child objects
|
||||||
await distributeChildUpdate(
|
await distributeChildUpdate(
|
||||||
previousExpandedObject,
|
previousExpandedObject,
|
||||||
{ ...previousExpandedObject, ...updateData },
|
{ ...previousExpandedObject, ...expandObjectIds(updateData) },
|
||||||
id,
|
id,
|
||||||
model
|
model
|
||||||
);
|
);
|
||||||
const updatedObject = { ...previousExpandedObject, ...updateData };
|
const updatedObject = { ...previousExpandedObject, ...expandObjectIds(updateData) };
|
||||||
|
|
||||||
// Update cache with the new version
|
// Update cache with the new version
|
||||||
await updateObjectCache({
|
await updateObjectCache({
|
||||||
|
|||||||
10
src/utils.js
10
src/utils.js
@ -667,7 +667,7 @@ async function newAuditLog(newValue, parentId, parentType, user) {
|
|||||||
|
|
||||||
await auditLog.save();
|
await auditLog.save();
|
||||||
|
|
||||||
await distributeNew(auditLog._id, 'auditLog');
|
await distributeNew(auditLog, 'auditLog');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function editAuditLog(oldValue, newValue, parentId, parentType, user) {
|
async function editAuditLog(oldValue, newValue, parentId, parentType, user) {
|
||||||
@ -698,7 +698,7 @@ async function editAuditLog(oldValue, newValue, parentId, parentType, user) {
|
|||||||
|
|
||||||
await auditLog.save();
|
await auditLog.save();
|
||||||
|
|
||||||
await distributeNew(auditLog._id, 'auditLog');
|
await distributeNew(auditLog, 'auditLog');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function editNotification(oldValue, newValue, parentId, parentType, user) {
|
async function editNotification(oldValue, newValue, parentId, parentType, user) {
|
||||||
@ -747,7 +747,7 @@ async function deleteAuditLog(deleteValue, parentId, parentType, user) {
|
|||||||
|
|
||||||
await auditLog.save();
|
await auditLog.save();
|
||||||
|
|
||||||
await distributeNew(auditLog._id, 'auditLog');
|
await distributeNew(auditLog, 'auditLog');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteNotification(object, parentId, parentType, user) {
|
async function deleteNotification(object, parentId, parentType, user) {
|
||||||
@ -799,7 +799,7 @@ async function subscribeAuditLog(parentId, parentType, user) {
|
|||||||
operation: 'subscribe',
|
operation: 'subscribe',
|
||||||
});
|
});
|
||||||
await auditLog.save();
|
await auditLog.save();
|
||||||
await distributeNew(auditLog._id, 'auditLog');
|
await distributeNew(auditLog, 'auditLog');
|
||||||
return auditLog;
|
return auditLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -812,7 +812,7 @@ async function unsubscribeAuditLog(parentId, parentType, user) {
|
|||||||
operation: 'unsubscribe',
|
operation: 'unsubscribe',
|
||||||
});
|
});
|
||||||
await auditLog.save();
|
await auditLog.save();
|
||||||
await distributeNew(auditLog._id, 'auditLog');
|
await distributeNew(auditLog, 'auditLog');
|
||||||
return auditLog;
|
return auditLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user