Skip to content

Commit

Permalink
fix: Passing publish=true in documents.update with published document…
Browse files Browse the repository at this point in the history
… errors
  • Loading branch information
tommoor committed Feb 24, 2024
1 parent 7685637 commit bc3271b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions server/routes/api/documents/documents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3032,6 +3032,7 @@ describe("#documents.update", () => {
id: document.id,
title: "Updated title",
text: "Updated text",
publish: true,
},
});
const body = await res.json();
Expand Down
5 changes: 4 additions & 1 deletion server/routes/api/documents/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,10 @@ router.post(
}

if (publish) {
authorize(user, "publish", document);
if (document.isDraft) {
authorize(user, "publish", document);
}

if (!document.collectionId) {
assertPresent(
collectionId,
Expand Down

0 comments on commit bc3271b

Please sign in to comment.