chore: add profile picture timeout

This commit is contained in:
Adhiraj Singh
2021-12-20 12:36:32 +05:30
parent c1301deda0
commit dbed7fef74
2 changed files with 5 additions and 4 deletions

View File

@@ -28,11 +28,12 @@ const makeChatsSocket = (config: LegacySocketConfig) => {
}) })
) )
const profilePictureUrl = async(jid: string) => { const profilePictureUrl = async(jid: string, timeoutMs?: number) => {
const response = await query({ const response = await query({
json: ['query', 'ProfilePicThumb', jid], json: ['query', 'ProfilePicThumb', jid],
expect200: false, expect200: false,
requiresPhoneConnection: false requiresPhoneConnection: false,
timeoutMs
}) })
return response.eurl as string | undefined return response.eurl as string | undefined
} }

View File

@@ -270,7 +270,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
* type = "preview" for a low res picture * type = "preview" for a low res picture
* type = "image for the high 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) jid = jidNormalizedUser(jid)
const result = await query({ const result = await query({
tag: 'iq', tag: 'iq',
@@ -282,7 +282,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
content: [ content: [
{ tag: 'picture', attrs: { type, query: 'url' } } { tag: 'picture', attrs: { type, query: 'url' } }
] ]
}) }, timeoutMs)
const child = getBinaryNodeChild(result, 'picture') const child = getBinaryNodeChild(result, 'picture')
return child?.attrs?.url return child?.attrs?.url
} }