diff --git a/app/containers/message/Audio.tsx b/app/containers/message/Audio.tsx index 516343ff6..bfe382a7c 100644 --- a/app/containers/message/Audio.tsx +++ b/app/containers/message/Audio.tsx @@ -51,7 +51,8 @@ const MessageAudio = ({ file, getCustomEmoji, author, isReply, style, msg }: IMe const audio = await downloadMediaFile({ downloadUrl: getAudioUrlToCache({ token: user.token, userId: user.id, url: audioUrl }), type: 'audio', - mimeType: file.audio_type + mimeType: file.audio_type, + encryption: file.encryption }); setFileUri(audio); setDownloadState('downloaded'); diff --git a/app/containers/message/Video.tsx b/app/containers/message/Video.tsx index 54a8bee4a..538364e46 100644 --- a/app/containers/message/Video.tsx +++ b/app/containers/message/Video.tsx @@ -161,7 +161,8 @@ const Video = ({ file, showAttachment, getCustomEmoji, style, isReply, msg }: IM const videoUri = await downloadMediaFile({ downloadUrl: video, type: 'video', - mimeType: file.video_type + mimeType: file.video_type, + encryption: file.encryption }); updateVideoCached(videoUri); } catch { diff --git a/app/lib/methods/handleMediaDownload.ts b/app/lib/methods/handleMediaDownload.ts index ffb445cc4..690c9435f 100644 --- a/app/lib/methods/handleMediaDownload.ts +++ b/app/lib/methods/handleMediaDownload.ts @@ -108,13 +108,11 @@ const ensureDirAsync = async (dir: string, intermediates = true): Promise export const getFilePath = ({ type, mimeType, - urlToCache, - encrypted = false + urlToCache }: { type: MediaTypes; mimeType?: string; urlToCache?: string; - encrypted?: boolean; }): string | null => { if (!urlToCache) { return null; @@ -212,7 +210,7 @@ export function downloadMediaFile({ return new Promise(async (resolve, reject) => { let downloadKey = ''; try { - const path = getFilePath({ type, mimeType, urlToCache: downloadUrl, encrypted: !!encryption }); + const path = getFilePath({ type, mimeType, urlToCache: downloadUrl }); if (!path) { return reject(); } @@ -225,6 +223,7 @@ export function downloadMediaFile({ } const decryptedFile = await decryptAESCTR(result.uri, encryption.key.k, encryption.iv); + console.log('🚀 ~ returnnewPromise ~ decryptedFile:', decryptedFile); if (decryptedFile) { return resolve(decryptedFile); }