Feat: change profile/group picture (#1916)

* feat: pfp

* Make eslint happy

* Fix typo

* Fix missing comma

* Update src/util/Injected.js

* ESLint

* Update src/util/Injected.js

* mfw purp breaks indentation

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
This commit is contained in:
Wictor Nogueira
2023-03-31 22:21:09 -03:00
committed by GitHub
parent 4846625119
commit dc16bbbdac
4 changed files with 131 additions and 1 deletions

View File

@@ -1178,6 +1178,31 @@ class Client extends EventEmitter {
return blockedContacts.map(contact => ContactFactory.create(this.client, contact));
}
/**
* Sets the current user's profile picture.
* @param {MessageMedia} media
* @returns {Promise<boolean>} Returns true if the picture was properly updated.
*/
async setProfilePicture(media) {
const success = await this.pupPage.evaluate((chatid, media) => {
return window.WWebJS.setPicture(chatid, media);
}, this.info.wid._serialized, media);
return success;
}
/**
* Deletes the current user's profile picture.
* @returns {Promise<boolean>} Returns true if the picture was properly deleted.
*/
async deleteProfilePicture() {
const success = await this.pupPage.evaluate((chatid) => {
return window.WWebJS.deletePicture(chatid);
}, this.info.wid._serialized);
return success;
}
}
module.exports = Client;