Skip to content

Commit

Permalink
feat: callback decryptFile interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Feb 12, 2021
1 parent 6a7e970 commit 8e6c0db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/api/model/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface Message {
notifyName: string;
from: string;
to: string;
fromMe: boolean;
author: string;
self: string;
ack: number;
Expand All @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions src/api/whatsapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8e6c0db

Please sign in to comment.