From 21d6fbed87598ca2055080e524c23361cd7a7aed Mon Sep 17 00:00:00 2001 From: Apoorv Mishra Date: Wed, 12 Apr 2023 05:08:25 +0530 Subject: [PATCH] Collection memberships required to be preloaded before publishing a document (#5187) --- server/routes/api/documents/documents.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/routes/api/documents/documents.ts b/server/routes/api/documents/documents.ts index 90b737857..b5819f4f9 100644 --- a/server/routes/api/documents/documents.ts +++ b/server/routes/api/documents/documents.ts @@ -915,7 +915,9 @@ router.post( collectionId, "collectionId is required to publish a draft without collection" ); - collection = await Collection.findByPk(collectionId as string); + collection = await Collection.scope({ + method: ["withMembership", user.id], + }).findByPk(collectionId!); } authorize(user, "publish", collection); }