fix: Handle private attachments without documentId (migration process)
This commit is contained in:
@ -17,10 +17,12 @@ router.post('attachments.redirect', auth(), async ctx => {
|
|||||||
const attachment = await Attachment.findByPk(id);
|
const attachment = await Attachment.findByPk(id);
|
||||||
|
|
||||||
if (attachment.isPrivate) {
|
if (attachment.isPrivate) {
|
||||||
|
if (attachment.documentId) {
|
||||||
const document = await Document.findByPk(attachment.documentId, {
|
const document = await Document.findByPk(attachment.documentId, {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
authorize(user, 'read', document);
|
authorize(user, 'read', document);
|
||||||
|
}
|
||||||
|
|
||||||
const accessUrl = await getSignedImageUrl(attachment.key);
|
const accessUrl = await getSignedImageUrl(attachment.key);
|
||||||
ctx.redirect(accessUrl);
|
ctx.redirect(accessUrl);
|
||||||
|
Reference in New Issue
Block a user