Skip to content

Commit

Permalink
✨ FIX: sendLinkWithAutoPreview now working on MD #2603
Browse files Browse the repository at this point in the history
  • Loading branch information
smashah committed Mar 29, 2022
1 parent a30b3cd commit 7ee118f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion patches.json

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions src/api/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,6 @@ public async testCallback(callbackToTest: SimpleListener, testData: any) : Prom
}

/**
* @deprecated Use [[sendLinkWithAutoPreview]] instead
* Sends a link to a chat that includes a link preview.
* @param thumb The base 64 data of the image you want to use as the thunbnail. This should be no more than 200x200px. Note: Dont need data url on this param
* @param url The link you want to send
Expand Down Expand Up @@ -1601,7 +1600,17 @@ public async testCallback(callbackToTest: SimpleListener, testData: any) : Prom
text?: Content,
thumbnail ?: Base64
) : Promise<boolean | MessageId> {
return await this.pup(
let linkData;
let thumb;
try {
linkData = (await axios.get(`${this._createConfig?.linkParser || "https://link.openwa.cloud/api"}?url=${url}`)).data;
log.info("Got link data", linkData)
if(!thumbnail) thumb = await getDUrl(linkData.image);
} catch (error) {
log.error(error)
}
if(linkData) return await this.sendMessageWithThumb(thumbnail || thumb,url,linkData.title, linkData.description, text, to);
else return await this.pup(
({ to,url, text, thumbnail }) => WAPI.sendLinkWithAutoPreview(to,url,text, thumbnail),
{ to,url, text, thumbnail }
) as Promise<MessageId | boolean>;
Expand Down

0 comments on commit 7ee118f

Please sign in to comment.