mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-20 20:49:14 +00:00
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.
This commit is contained in:
@@ -190,9 +190,15 @@ class Message extends Base {
|
|||||||
const msg = window.Store.Msg.get(msgId);
|
const msg = window.Store.Msg.get(msgId);
|
||||||
|
|
||||||
if(msg.mediaData.mediaStage != 'RESOLVED') {
|
if(msg.mediaData.mediaStage != 'RESOLVED') {
|
||||||
|
// try to resolve media
|
||||||
await msg.downloadMedia(true, 1);
|
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 buffer = await window.WWebJS.downloadBuffer(msg.clientUrl);
|
||||||
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
|
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
|
||||||
const data = await window.WWebJS.readBlobAsync(decrypted._blob);
|
const data = await window.WWebJS.readBlobAsync(decrypted._blob);
|
||||||
|
|||||||
Reference in New Issue
Block a user