From 5934ec531f711ca97bb73895974ced401070a0a4 Mon Sep 17 00:00:00 2001 From: "Pedro S. Lopez" Date: Sun, 15 Mar 2020 15:20:50 -0400 Subject: [PATCH] fix: return undefined when attempting to download nonexistent media This could occur when the user has deleted the media and it can no longer be downloaded. --- src/structures/Message.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/structures/Message.js b/src/structures/Message.js index a2c883f..35643d3 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -190,8 +190,14 @@ class Message extends Base { const msg = window.Store.Msg.get(msgId); if(msg.mediaData.mediaStage != 'RESOLVED') { + // try to resolve media await msg.downloadMedia(true, 1); } + + if(msg.mediaData.mediaStage != 'RESOLVED') { + // media could not be downloaded + return undefined; + } const buffer = await window.WWebJS.downloadBuffer(msg.clientUrl); const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);