From b15ec768d32de98a2dadf9ef8ea36f024525c225 Mon Sep 17 00:00:00 2001 From: Lucas Rosa Date: Mon, 26 Oct 2020 16:23:26 -0300 Subject: [PATCH 1/3] fix: show multiple vcard as array in body --- src/structures/Message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index 4eaaba2..5214fe8 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -46,7 +46,7 @@ class Message extends Base { * Message content * @type {string} */ - this.body = this.hasMedia ? data.caption || '' : data.body || ''; + this.body = data.type === MessageTypes.CONTACT_CARD_MULTI ? data.vcardList.map((c) => c.vcard) : this.hasMedia ? data.caption || '' : data.body || ''; /** * Message type From 75296b652bca722b689c2d64b34e3b04bb413130 Mon Sep 17 00:00:00 2001 From: Lucas Rosa Date: Mon, 26 Oct 2020 19:49:06 -0300 Subject: [PATCH 2/3] feat: add received vcards to the message. --- src/structures/Message.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index 5214fe8..f30f98e 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -46,7 +46,7 @@ class Message extends Base { * Message content * @type {string} */ - this.body = data.type === MessageTypes.CONTACT_CARD_MULTI ? data.vcardList.map((c) => c.vcard) : this.hasMedia ? data.caption || '' : data.body || ''; + this.body = this.hasMedia ? data.caption || '' : data.body || ''; /** * Message type @@ -117,6 +117,12 @@ class Message extends Base { */ this.location = data.type === MessageTypes.LOCATION ? new Location(data.lat, data.lng, data.loc) : undefined; + /** + * List of vcards contained in the message, if the message is a vcard or multiple vcards. + * @type {Array} + */ + this.vcards = data.type === MessageTypes.CONTACT_CARD_MULTI ? data.vcardList.map((c) => c.vcard) : data.type === MessageTypes.CONTACT_CARD ? [data.body] : []; + /** * Indicates the mentions in the message body. * @type {Array} From 054ef4a84fe6fadcda85c7f8621984b42718bfcc Mon Sep 17 00:00:00 2001 From: Pedro Lopez Date: Thu, 5 Nov 2020 02:06:13 -0400 Subject: [PATCH 3/3] add typings --- index.d.ts | 2 ++ src/structures/Message.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 81824c3..ce4c1ad 100644 --- a/index.d.ts +++ b/index.d.ts @@ -465,6 +465,8 @@ declare namespace WAWebJS { isForwarded: boolean, /** Location information contained in the message, if the message is type "location" */ location: Location, + /** List of vCards contained in the message */ + vCards: string[], /** MediaKey that represents the sticker 'ID' */ mediaKey?: string, /** Indicates the mentions in the message body. */ diff --git a/src/structures/Message.js b/src/structures/Message.js index f30f98e..5e259a0 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -118,10 +118,10 @@ class Message extends Base { this.location = data.type === MessageTypes.LOCATION ? new Location(data.lat, data.lng, data.loc) : undefined; /** - * List of vcards contained in the message, if the message is a vcard or multiple vcards. + * List of vCards contained in the message. * @type {Array} */ - this.vcards = data.type === MessageTypes.CONTACT_CARD_MULTI ? data.vcardList.map((c) => c.vcard) : data.type === MessageTypes.CONTACT_CARD ? [data.body] : []; + this.vCards = data.type === MessageTypes.CONTACT_CARD_MULTI ? data.vcardList.map((c) => c.vcard) : data.type === MessageTypes.CONTACT_CARD ? [data.body] : []; /** * Indicates the mentions in the message body.