From dbed7fef741c8cd5ed3b79ed4690b6cdb8f5881b Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 20 Dec 2021 12:36:32 +0530 Subject: [PATCH] chore: add profile picture timeout --- src/LegacySocket/chats.ts | 5 +++-- src/Socket/chats.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/LegacySocket/chats.ts b/src/LegacySocket/chats.ts index fe01273..c9612d9 100644 --- a/src/LegacySocket/chats.ts +++ b/src/LegacySocket/chats.ts @@ -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 } diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 49448e0..5e27a84 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -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 }