mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-22 21:40:08 +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') {
|
||||
// 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
|
||||
return undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({
|
||||
directPath: msg.directPath,
|
||||
encFilehash: msg.encFilehash,
|
||||
@@ -338,7 +342,10 @@ class Message extends Base {
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
};
|
||||
|
||||
} catch (e) {
|
||||
if(e.status && e.status === 404) return undefined;
|
||||
throw e;
|
||||
}
|
||||
}, this.id._serialized);
|
||||
|
||||
if (!result) return undefined;
|
||||
|
||||
Reference in New Issue
Block a user