diff --git a/src/Client.js b/src/Client.js index 2bed2c2..2b7aaec 100644 --- a/src/Client.js +++ b/src/Client.js @@ -547,6 +547,18 @@ class Client extends EventEmitter { }, chatId); } + /** + * Returns the contact ID's profile picture URL, if privacy settings allow it + * @returns {Promise} + */ + async getProfilePicUrl(contactId) { + const profilePic = await this.pupPage.evaluate((contactId) => { + return window.Store.Wap.profilePicFind(contactId); + }, contactId); + + return profilePic ? profilePic.eurl : undefined; + } + /** * Force reset of connection state for the client */ diff --git a/src/structures/Contact.js b/src/structures/Contact.js index 60fd3b7..2321ccc 100644 --- a/src/structures/Contact.js +++ b/src/structures/Contact.js @@ -103,11 +103,7 @@ class Contact extends Base { * @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; + return await this.client.getProfilePicUrl(this.id._serialized); } }