fix: documents.publish event not triggered if nothing else changed in doc (#2728)

This commit is contained in:
Tom Moor
2021-11-03 18:43:01 -07:00
committed by GitHub
parent ad3bb98087
commit 89115a53ca
2 changed files with 49 additions and 26 deletions

View File

@@ -1067,32 +1067,30 @@ router.post("documents.update", auth(), async (ctx) => {
throw err;
}
if (changed) {
if (publish) {
await Event.create({
name: "documents.publish",
documentId: document.id,
collectionId: document.collectionId,
teamId: document.teamId,
actorId: user.id,
data: { title: document.title },
ip: ctx.request.ip,
});
} else {
await Event.create({
name: "documents.update",
documentId: document.id,
collectionId: document.collectionId,
teamId: document.teamId,
actorId: user.id,
data: {
autosave,
done,
title: document.title,
},
ip: ctx.request.ip,
});
}
if (publish) {
await Event.create({
name: "documents.publish",
documentId: document.id,
collectionId: document.collectionId,
teamId: document.teamId,
actorId: user.id,
data: { title: document.title },
ip: ctx.request.ip,
});
} else if (changed) {
await Event.create({
name: "documents.update",
documentId: document.id,
collectionId: document.collectionId,
teamId: document.teamId,
actorId: user.id,
data: {
autosave,
done,
title: document.title,
},
ip: ctx.request.ip,
});
}
if (document.title !== previousTitle) {