From f2b286a3198395b0e18c18168b06450585adf054 Mon Sep 17 00:00:00 2001 From: Pedro Lopez Date: Sat, 8 Feb 2020 01:23:29 -0400 Subject: [PATCH] feat: get contact's profile picture --- README.md | 1 + src/structures/Contact.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 3146fb1..62c2a77 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/ | Promote/demote group participants | ✅ | | Mention users | _pending_ | | Get contact info | ✅ | +| Get profile pictures | ✅ | Something missing? Make an issue and let us know! diff --git a/src/structures/Contact.js b/src/structures/Contact.js index ccaf682..7cd7dee 100644 --- a/src/structures/Contact.js +++ b/src/structures/Contact.js @@ -91,6 +91,18 @@ class Contact extends Base { return super._patch(data); } + + /** + * Returns the contact's profile picture URL, if privacy settings allow it + * @returns {Promise} + */ + async getProfilePicUrl() { + const profilePic = await this.client.pupPage.evaluate((contactId) => { + return window.Store.Wap.profilePicFind(contactId); + }, this.id._serialized); + + return profilePic ? profilePic.eurl : undefined; + } }