Skip to content

Commit

Permalink
Fix: Unable to open E2EE PDFs (#5775)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello authored Jul 11, 2024
1 parent b1df2af commit 6982fd2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/lib/methods/helpers/fileDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ export const fileDownload = async (url: string, attachment?: IAttachment, fileNa

export const fileDownloadAndPreview = async (url: string, attachment: IAttachment, messageId: string): Promise<void> => {
try {
const file = await fileDownload(url, attachment);
let file = url;
// If url starts with file://, we assume it's a local file and we don't download/decrypt it
if (!file.startsWith('file://')) {
file = await fileDownload(file, attachment);

if (attachment.encryption) {
if (!attachment.hashes?.sha256) {
throw new Error('Missing checksum');
if (attachment.encryption) {
if (!attachment.hashes?.sha256) {
throw new Error('Missing checksum');
}
await Encryption.addFileToDecryptFileQueue(messageId, file, attachment.encryption, attachment.hashes?.sha256);
}
await Encryption.addFileToDecryptFileQueue(messageId, file, attachment.encryption, attachment.hashes?.sha256);
}

await FileViewer.open(file, {
Expand Down

0 comments on commit 6982fd2

Please sign in to comment.