mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-21 04:59:14 +00:00
fix: correctly resolve media that hasn't been downloaded (#763)
* fix: correctly abort if media does not exist * catch 404s * dont throw for media that cant be fetched
This commit is contained in:
@@ -313,14 +313,18 @@ class Message extends Base {
|
|||||||
|
|
||||||
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
||||||
// try to resolve media
|
// try to resolve media
|
||||||
await msg.downloadMedia(true, 1);
|
await msg.downloadMedia({
|
||||||
|
downloadEvenIfExpensive: true,
|
||||||
|
rmrReason: 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.mediaData.mediaStage.includes('ERROR')) {
|
if (msg.mediaData.mediaStage.includes('ERROR') || msg.mediaData.mediaStage === 'FETCHING') {
|
||||||
// media could not be downloaded
|
// media could not be downloaded
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({
|
const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({
|
||||||
directPath: msg.directPath,
|
directPath: msg.directPath,
|
||||||
encFilehash: msg.encFilehash,
|
encFilehash: msg.encFilehash,
|
||||||
@@ -338,7 +342,10 @@ class Message extends Base {
|
|||||||
mimetype: msg.mimetype,
|
mimetype: msg.mimetype,
|
||||||
filename: msg.filename
|
filename: msg.filename
|
||||||
};
|
};
|
||||||
|
} catch (e) {
|
||||||
|
if(e.status && e.status === 404) return undefined;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}, this.id._serialized);
|
}, this.id._serialized);
|
||||||
|
|
||||||
if (!result) return undefined;
|
if (!result) return undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user