-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding / Deleting Profile Picture #652
Conversation
Update to v.1.12.6
When these methods will be merged? They would be very usefull :-) |
Looking forward to getting this functionality!! Really appreciate if you can merge this. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thanks for adding this.
I think to avoid confusion we should leave client.setProfilePicture
and client.removeProfilePicture
to deal with the current user's profile and let groupChat.setProfilePicture
/ groupChat.removeProfilePicture
deal with the group's picture. You can then move common functionality to Injected.js
* @returns {Promise<Boolean>} true if it succeeded / false if it didn't delete the profile picture. | ||
*/ | ||
async deleteProfilePicture() { | ||
return await this.client.setProfilePicture(this.id._serialized); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be calling deleteProfilePicture
instead of setProfilePicture
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
I usually make PRs locally and test then re-type it out in github's editor..
I am going to use git functions from now on, overall less mistakes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting an eye on this, sorry for the confusion
replaced with single quotes
when I try to do that I get an erro on the window.mR.findModule('setProfilePic')[0]; is there a solution for this? |
I will check it out. i still have to re-factor the code anyways so I will have to find the module by collection and not the method name itself Best regards, |
As you might have seen, the PR has been put on draft mode and the eslint failed |
Very nice this!!!! I hope to use it soon. Congrats @PurpShell & @pedroslopez |
eslint fix for your Pull request
@PurpShell Hello! It's possible you share function Util.formatImageToProfilePic() ?
|
|
this is different from my way, though i haven't been able to push since i have been getting issues with also the way you do this is very bad, resizing an image of any dimension / aspect ratio, and also not providing the format in JPEG. |
It's temporary, but it works... 😁 |
I am working on this pull request again! Sorry for the long wait! I'll work more on this on my windows machine, since no sharp issues there! So far I've tried to imitate the original way the function worked, but it seems like something has either changed or i'm getting it wrong. Excuse me for not providing the util function! I reset my |
Update: even after fixing the util function, some change has occurred in whatsapp web that doesn't allow me to set a profile picture I'll look into it in the following days |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
my issues with sharp aren't bad.. I think I can try to extract the tools wa uses to crop and get the photo |
Since I am getting rid of sharp, which this PR uses, I will also find the functions whatsapp uses to resize the image, and finally settle this issue |
Hi, when you will merge that? =) |
Profile Picture functionality
INFO
This pull request is adding the way to set and delete profile pictures.
Currently, this only works with chats in cache, (ProfilePicThumb),
I will see if I can change that though..
It automatically resizes any unfitting dimensions, picking the left of an image.. Recommended dimensions are 640*640.
YOU CAN ONLY SET / DELETE PFPs TO GROUPS and YOURSELF
(you must be able to do it on your own by default)
(you must have group admin on any chat that has restricting editing info only to admins)
EDIT (May 4, 2021): THIS HAS BEEN TESTED FOR 7 DAYS.. All seems working with no bans and no potential risk of being banned.
VIDEO DEMO:
output.mp4
USAGE
This pull request adds two methods.
client.setProfilePicture(id, picture)
:- Parameters:
- id : String (Chat ID to set)
- picture: MessageMedia instance of the image you want to be set.
- Returns:
Image URL /
False
client.deleteProfilePicture(id)
:- Parameters:
- id : String (Chat ID to delete from)
- Returns:
True
/False
Also 2 sub-methods for a GroupChat instance:
chat.setProfilePicture(picture)
:- Parameters:
- picture: MessageMedia instance of the image you want to be set.
- Returns:
Image URL /
False
chat.deleteProfilePicture()
:- Parameters:
none
- Returns:
True
/False