mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix(master): New profile update/removal endpoint (inspired by #1048)
This commit is contained in:
@@ -220,11 +220,21 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
|
|
||||||
/** update the profile picture for yourself or a group */
|
/** update the profile picture for yourself or a group */
|
||||||
const updateProfilePicture = async(jid: string, content: WAMediaUpload) => {
|
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)
|
const { img } = await generateProfilePicture(content)
|
||||||
await query({
|
await query({
|
||||||
tag: 'iq',
|
tag: 'iq',
|
||||||
attrs: {
|
attrs: {
|
||||||
to: jidNormalizedUser(jid),
|
target: targetJid,
|
||||||
|
to: S_WHATSAPP_NET,
|
||||||
type: 'set',
|
type: 'set',
|
||||||
xmlns: 'w:profile:picture'
|
xmlns: 'w:profile:picture'
|
||||||
},
|
},
|
||||||
@@ -240,10 +250,20 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
|
|
||||||
/** remove the profile picture for yourself or a group */
|
/** remove the profile picture for yourself or a group */
|
||||||
const removeProfilePicture = async(jid: string) => {
|
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({
|
await query({
|
||||||
tag: 'iq',
|
tag: 'iq',
|
||||||
attrs: {
|
attrs: {
|
||||||
to: jidNormalizedUser(jid),
|
target: targetJid,
|
||||||
|
to: S_WHATSAPP_NET,
|
||||||
type: 'set',
|
type: 'set',
|
||||||
xmlns: 'w:profile:picture'
|
xmlns: 'w:profile:picture'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user