fix: Handle private attachments without documentId (migration process)

This commit is contained in:
Tom Moor committed 2020-02-17 09:38:34 -08:00
1 parent 3b0b37628e
commit 902e7a4772
1 file changed
+6 -4
+6 -4
View File
@@ -17,10 +17,12 @@ router.post('attachments.redirect', auth(), async ctx => {
const attachment = await Attachment.findByPk(id);
if (attachment.isPrivate) {
const document = await Document.findByPk(attachment.documentId, {
userId: user.id,
});
authorize(user, 'read', document);
if (attachment.documentId) {
const document = await Document.findByPk(attachment.documentId, {
userId: user.id,
});
authorize(user, 'read', document);
}
const accessUrl = await getSignedImageUrl(attachment.key);
ctx.redirect(accessUrl);