feat: Add support to suspicious links (#642)

This commit is contained in:
Rajeh Taher
2021-07-12 21:03:11 +03:00
committed by GitHub
parent 1d49f74ab4
commit 54a07fa22f
3 changed files with 9 additions and 5 deletions

7
index.d.ts vendored
View File

@@ -349,7 +349,7 @@ declare namespace WAWebJS {
reply: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>, reply: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
} }
/** whatsapp web url */ /** whatsapp web url */
export const WhatsWebURL: string export const WhatsWebURL: string
@@ -545,7 +545,10 @@ declare namespace WAWebJS {
/** Message type */ /** Message type */
type: MessageTypes, type: MessageTypes,
/** Links included in the message. */ /** Links included in the message. */
links: string[], links: Array<{
link: string,
isSuspicious: boolean
}>,
/** Order ID */ /** Order ID */
orderId: string, orderId: string,
/** title */ /** title */

View File

@@ -200,7 +200,8 @@ class Message extends Base {
/** /**
* Links included in the message. * Links included in the message.
* @type {Array<string>} * @type {Array<{link: string, isSuspicious: boolean}>}
*
*/ */
this.links = data.links; this.links = data.links;

View File

@@ -264,8 +264,7 @@ exports.LoadUtils = () => {
const msg = message.serialize(); const msg = message.serialize();
msg.isStatusV3 = message.isStatusV3; msg.isStatusV3 = message.isStatusV3;
msg.links = (message.getLinks()).map(link => link.href); msg.links = (message.getLinks()).map(link => ({ link: link.href, isSuspicious: link.suspiciousCharacters?.size ? true : false}));
if (msg.buttons) { if (msg.buttons) {
msg.buttons = msg.buttons.serialize(); msg.buttons = msg.buttons.serialize();
} }
@@ -275,6 +274,7 @@ exports.LoadUtils = () => {
return msg; return msg;
}; };
window.WWebJS.getChatModel = async chat => { window.WWebJS.getChatModel = async chat => {
let res = chat.serialize(); let res = chat.serialize();
res.isGroup = chat.isGroup; res.isGroup = chat.isGroup;