fix: documentUpdater called without change can result in lastModifiedById being updated

This commit is contained in:
Tom Moor
2022-05-22 22:39:54 +01:00
parent a78ad8dec2
commit 73de15fd5d
3 changed files with 59 additions and 5 deletions

View File

@@ -68,16 +68,12 @@ export default async function documentUpdater({
}
}
document.lastModifiedById = user.id;
const changed = document.changed();
if (publish) {
document.lastModifiedById = user.id;
await document.publish(user.id, { transaction });
} else {
await document.save({ transaction });
}
if (publish) {
await Event.create(
{
name: "documents.publish",
@@ -93,6 +89,9 @@ export default async function documentUpdater({
{ transaction }
);
} else if (changed) {
document.lastModifiedById = user.id;
await document.save({ transaction });
await Event.create(
{
name: "documents.update",