fix: properly download media if it has not been loaded

This issue occurred when attempting to download media from old messages.
This commit is contained in:
Pedro Lopez
2020-03-14 17:37:59 -04:00
parent 5e9deff8a9
commit 8599a6d918

View File

@@ -188,6 +188,11 @@ class Message extends Base {
const {data, mimetype, filename} = await this.client.pupPage.evaluate(async (msgId) => {
const msg = window.Store.Msg.get(msgId);
if(msg.mediaData.mediaStage != 'RESOLVED') {
await msg.downloadMedia(true, 1);
}
const buffer = await window.WWebJS.downloadBuffer(msg.clientUrl);
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
const data = await window.WWebJS.readBlobAsync(decrypted._blob);