Skip to content

Commit

Permalink
fix(master): New profile update/removal endpoint (inspired by #1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
PurpShell authored Sep 22, 2024
1 parent 767347b commit 70f0321
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Socket/chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,21 @@ export const makeChatsSocket = (config: SocketConfig) => {

/** update the profile picture for yourself or a group */
const updateProfilePicture = async(jid: string, content: WAMediaUpload) => {
let targetJid = ''
if(!jid) {
throw new Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update')
}

if(jidNormalizedUser(jid) !== jidNormalizedUser(authState.creds.me!.id)) {
targetJid = jid // in case it is someone other than us
}

const { img } = await generateProfilePicture(content)
await query({
tag: 'iq',
attrs: {
to: jidNormalizedUser(jid),
target: targetJid,
to: S_WHATSAPP_NET,
type: 'set',
xmlns: 'w:profile:picture'
},
Expand All @@ -240,10 +250,20 @@ export const makeChatsSocket = (config: SocketConfig) => {

/** remove the profile picture for yourself or a group */
const removeProfilePicture = async(jid: string) => {
let targetJid = ''
if(!jid) {
throw new Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update')
}

if(jidNormalizedUser(jid) !== jidNormalizedUser(authState.creds.me!.id)) {
targetJid = jid // in case it is someone other than us
}

await query({
tag: 'iq',
attrs: {
to: jidNormalizedUser(jid),
target: targetJid,
to: S_WHATSAPP_NET,
type: 'set',
xmlns: 'w:profile:picture'
}
Expand Down

0 comments on commit 70f0321

Please sign in to comment.