Special handling of file URLs

This commit is contained in:
Jackson Harper
2023-10-18 10:37:21 +08:00
parent 78843fff14
commit b88c64424f
2 changed files with 9 additions and 1 deletions

View File

@ -109,9 +109,12 @@ export const uploadFileRequestResolver = authorized<
input.contentType
)
// If this is a file URL, we swap in a special URL
const attachmentUrl = `https://omnivore.app/attachments/${uploadFilePathName}`
if (isFileUrl(input.url)) {
await authTrx(async (tx) => {
await tx.getRepository(UploadFile).update(uploadFileId, {
url: attachmentUrl,
status: UploadFileStatus.Initialized,
})
})

View File

@ -142,7 +142,12 @@ export function emailAttachmentRouter() {
return res.status(400).send('BAD REQUEST')
}
const uploadFileUrlOverride = `https://omnivore.app/attachments/${uploadFileId}/${uploadFile.fileName}`
const uploadFilePathName = generateUploadFilePathName(
uploadFileId,
uploadFile.fileName
)
const uploadFileUrlOverride = `https://omnivore.app/attachments/${uploadFilePathName}`
const uploadFileHash = uploadFileDetails.md5Hash
const itemType =
uploadFile.contentType === 'application/pdf'