mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
chore: add profile picture timeout
This commit is contained in:
@@ -28,11 +28,12 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
|
||||
})
|
||||
)
|
||||
|
||||
const profilePictureUrl = async(jid: string) => {
|
||||
const profilePictureUrl = async(jid: string, timeoutMs?: number) => {
|
||||
const response = await query({
|
||||
json: ['query', 'ProfilePicThumb', jid],
|
||||
expect200: false,
|
||||
requiresPhoneConnection: false
|
||||
requiresPhoneConnection: false,
|
||||
timeoutMs
|
||||
})
|
||||
return response.eurl as string | undefined
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
* type = "preview" for a low res picture
|
||||
* type = "image for the high res picture"
|
||||
*/
|
||||
const profilePictureUrl = async(jid: string, type: 'preview' | 'image' = 'preview') => {
|
||||
const profilePictureUrl = async(jid: string, type: 'preview' | 'image' = 'preview', timeoutMs?: number) => {
|
||||
jid = jidNormalizedUser(jid)
|
||||
const result = await query({
|
||||
tag: 'iq',
|
||||
@@ -282,7 +282,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
content: [
|
||||
{ tag: 'picture', attrs: { type, query: 'url' } }
|
||||
]
|
||||
})
|
||||
}, timeoutMs)
|
||||
const child = getBinaryNodeChild(result, 'picture')
|
||||
return child?.attrs?.url
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user