fix: Handle private attachments without documentId (migration process)

This commit is contained in:
Tom Moor
2020-02-17 09:38:34 -08:00
parent 3b0b37628e
commit 902e7a4772

View File

@ -17,10 +17,12 @@ router.post('attachments.redirect', auth(), async ctx => {
const attachment = await Attachment.findByPk(id);
if (attachment.isPrivate) {
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);