minor fixes

This commit is contained in:
Adhiraj
2020-08-07 22:39:05 +05:30
parent 87c47994a7
commit 9d8d60d245
3 changed files with 11 additions and 10 deletions

1
.gitignore vendored
View File

@@ -5,7 +5,6 @@ package-lock.json
*/.DS_Store */.DS_Store
.DS_Store .DS_Store
.env .env
lib
auth_info_browser.json auth_info_browser.json
yarn.lock yarn.lock
browser-messages.json browser-messages.json

View File

@@ -264,4 +264,12 @@ WAClientTest('Events', (client) => {
const response = await client.sendMessage(testJid, 'My Name Jeff', MessageType.text) const response = await client.sendMessage(testJid, 'My Name Jeff', MessageType.text)
await promiseTimeout(10000, waitForUpdate()) await promiseTimeout(10000, waitForUpdate())
}) })
/*it('should retreive all conversations', async () => {
const [chats] = await client.receiveChatsAndContacts (10000)
for (let chat of chats.all()) {
console.log ('receiving ' + chat.jid)
const convo = await client.loadConversation (chat.jid.replace('@s.whatsapp.net', '@c.us'), 25)
await createTimeout (200)
}
})*/
}) })

View File

@@ -221,17 +221,11 @@ export default class WAConnectionBase {
* @param [binaryTags] the tags to attach if the query is supposed to be sent encoded in binary * @param [binaryTags] the tags to attach if the query is supposed to be sent encoded in binary
* @param [timeoutMs] timeout after which the query will be failed (set to null to disable a timeout) * @param [timeoutMs] timeout after which the query will be failed (set to null to disable a timeout)
* @param [tag] the tag to attach to the message * @param [tag] the tag to attach to the message
* recieved JSON
*/ */
async queryExpecting200( async queryExpecting200(json: any[] | WANode, binaryTags?: WATag, timeoutMs?: number, tag?: string) {
json: any[] | WANode,
binaryTags: WATag = null,
timeoutMs: number = null,
tag: string = null,
) {
const response = await this.query(json, binaryTags, timeoutMs, tag) const response = await this.query(json, binaryTags, timeoutMs, tag)
if (response.status && Math.floor(+response.status / 100) !== 2) { if (response.status && Math.floor(+response.status / 100) !== 2) {
throw new BaileysError(`Unexpected status code: ${response.status}`, {query: json}) throw new BaileysError(`Unexpected status code in '${json[0] || 'generic query'}': ${response.status}`, {query: json})
} }
return response return response
} }
@@ -243,7 +237,7 @@ export default class WAConnectionBase {
* @param tag the tag to attach to the message * @param tag the tag to attach to the message
* recieved JSON * recieved JSON
*/ */
async query(json: any[] | WANode, binaryTags: WATag = null, timeoutMs: number = null, tag: string = null) { async query(json: any[] | WANode, binaryTags?: WATag, timeoutMs?: number, tag?: string) {
if (binaryTags) tag = await this.sendBinary(json as WANode, binaryTags, tag) if (binaryTags) tag = await this.sendBinary(json as WANode, binaryTags, tag)
else tag = await this.sendJSON(json, tag) else tag = await this.sendJSON(json, tag)