feat: get links included in message (#457)

This commit is contained in:
Pedro S. Lopez
2020-12-25 19:08:25 -04:00
parent e2a642a81b
commit 8b101d1f3d
3 changed files with 13 additions and 0 deletions

2
index.d.ts vendored
View File

@@ -499,6 +499,8 @@ declare namespace WAWebJS {
to: string, to: string,
/** Message type */ /** Message type */
type: MessageTypes, type: MessageTypes,
/** Links included in the message. */
links: string[],
/** Deletes the message from the chat */ /** Deletes the message from the chat */
delete: (everyone?: boolean) => Promise<void>, delete: (everyone?: boolean) => Promise<void>,

View File

@@ -133,6 +133,12 @@ class Message extends Base {
this.mentionedIds = data.mentionedJidList; this.mentionedIds = data.mentionedJidList;
} }
/**
* Links included in the message.
* @type {Array<string>}
*/
this.links = data.links;
return super._patch(data); return super._patch(data);
} }

View File

@@ -250,11 +250,16 @@ exports.LoadUtils = () => {
window.WWebJS.getMessageModel = message => { window.WWebJS.getMessageModel = message => {
const msg = message.serialize(); const msg = message.serialize();
msg.isStatusV3 = message.isStatusV3; msg.isStatusV3 = message.isStatusV3;
msg.links = (message.getLinks()).map(link => link.href);
if (msg.buttons) { if (msg.buttons) {
msg.buttons = msg.buttons.serialize(); msg.buttons = msg.buttons.serialize();
} }
delete msg.pendingAckUpdate; delete msg.pendingAckUpdate;
return msg; return msg;
}; };