From 8e6c0db86d5f8030d5d62920e8e868164ca33748 Mon Sep 17 00:00:00 2001 From: jonalan Date: Fri, 12 Feb 2021 17:14:00 -0300 Subject: [PATCH] feat: callback decryptFile interface --- src/api/model/message.ts | 5 ++++- src/api/whatsapp.ts | 17 +++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/api/model/message.ts b/src/api/model/message.ts index 4dd707417..f21be7370 100644 --- a/src/api/model/message.ts +++ b/src/api/model/message.ts @@ -60,6 +60,7 @@ export interface Message { notifyName: string; from: string; to: string; + fromMe: boolean; author: string; self: string; ack: number; @@ -68,10 +69,12 @@ export interface Message { star: boolean; recvFresh: boolean; interactiveAnnotations: any[]; + caption: string; + filename: string; clientUrl: string; deprecatedMms3Url: string; - directPath: string; mimetype: string; + directPath: string; filehash: string; uploadhash: string; size: number; diff --git a/src/api/whatsapp.ts b/src/api/whatsapp.ts index 93f459049..66109ee31 100644 --- a/src/api/whatsapp.ts +++ b/src/api/whatsapp.ts @@ -167,17 +167,18 @@ export class Whatsapp extends ControlsLayer { * @returns Decrypted file buffer (null otherwise) */ public async decryptFile(message: Message) { - const options = makeOptions(useragentOverride); - const clientUrl = - message.clientUrl !== undefined - ? message.clientUrl - : message.deprecatedMms3Url; - if (!clientUrl) + const options = makeOptions(useragentOverride), + clientUrl = + message.clientUrl !== undefined + ? message.clientUrl + : message.deprecatedMms3Url; + if (!clientUrl) { throw new Error( 'message is missing critical data needed to download the file.' ); - let haventGottenImageYet = true; - let res: any; + } + let haventGottenImageYet: boolean = true, + res: any; try { while (haventGottenImageYet) { res = await axios.get(message.clientUrl.trim(), options);