diff --git a/README.md b/README.md index 2bf610e..ac59e10 100644 --- a/README.md +++ b/README.md @@ -496,8 +496,11 @@ await conn.sendMessage( ``` - To get the display picture of some person/group ``` ts + // for low res picture const ppUrl = await conn.profilePictureUrl("xyz@g.us") console.log("download profile picture from: " + ppUrl) + // for high res picture + const ppUrl = await conn.profilePictureUrl("xyz@g.us", 'image') ``` - To change your display picture or a group's ``` ts diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index e6a7e26..66fe476 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -11,8 +11,6 @@ export const makeChatsSocket = (config: SocketConfig) => { ev, ws, authState, - processMessage, - relayMessage, generateMessageTag, sendNode, query @@ -221,7 +219,12 @@ export const makeChatsSocket = (config: SocketConfig) => { ) } - const profilePictureUrl = async(jid: string) => { + /** + * fetch the profile picture of a user/group + * type = "preview" for a low res picture + * type = "image for the high res picture" + */ + const profilePictureUrl = async(jid: string, type: 'preview' | 'image' = 'preview') => { jid = jidNormalizedUser(jid) const result = await query({ tag: 'iq', @@ -231,7 +234,7 @@ export const makeChatsSocket = (config: SocketConfig) => { xmlns: 'w:profile:picture' }, content: [ - { tag: 'picture', attrs: { type: 'preview', query: 'url' } } + { tag: 'picture', attrs: { type, query: 'url' } } ] }) const child = getBinaryNodeChild(result, 'picture')