From 6d7f008af08ef0da34d5f6412232376f3f54d500 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 22 May 2022 08:51:47 +0100 Subject: [PATCH] fix: Sidebar missing on public documents when accessing with valid team token --- server/routes/api/documents.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/routes/api/documents.ts b/server/routes/api/documents.ts index 7d3042cf0..5e756738d 100644 --- a/server/routes/api/documents.ts +++ b/server/routes/api/documents.ts @@ -467,10 +467,16 @@ async function loadDocument({ await share.update({ lastAccessedAt: new Date(), }); + + // Cannot use document.collection here as it does not include the + // documentStructure by default through the relationship. + collection = await Collection.findByPk(document.collectionId); + invariant(collection, "collection not found"); + return { document, share, - collection: document.collection, + collection, }; }