Added fetch agent

This commit is contained in:
Adhiraj
2020-10-06 12:55:38 +05:30
parent 9c34f35a7b
commit 15ba4b66fb
3 changed files with 12 additions and 4 deletions

View File

@@ -202,9 +202,15 @@ WAConnectionTest('Messages', conn => {
for (let i = 0; i < messages.length;i++) {
assert.deepEqual (messages[i].key, msgs[i].key, `failed equal at ${i}`)
}
}
cursor = msgs[0].key
msgs = await conn.fetchMessagesFromWA (testJid, 20, cursor)
messages = (await conn.loadMessages (testJid, 20, cursor)).messages
for (let i = 0; i < messages.length;i++) {
assert.deepEqual (messages[i].key, msgs[i].key, `failed equal at ${i}`)
}
}
})
it('should deliver a message', async () => {
const waitForUpdate =

View File

@@ -377,7 +377,7 @@ export class WAConnection extends EventEmitter {
method,
body,
headers: { Origin: DEFAULT_ORIGIN, ...(headers || {}) },
agent: agent || this.connectOptions.agent
agent: agent || this.connectOptions.fetchAgent
})
)
generateMessageTag (longTag: boolean = false) {

View File

@@ -84,8 +84,10 @@ export type WAConnectOptions = {
/** max time for the phone to respond to a connectivity test */
phoneResponseTime?: number
connectCooldownMs?: number
/** agent which can be used for proxying connections */
/** agent used for WS connections */
agent?: Agent
/** agent used for fetch requests -- uploading/downloading media */
fetchAgent?: Agent
}
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
export const URL_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)?/gi