Unread fix + regen QR code changes + Browser message decoding

This commit is contained in:
Adhiraj
2020-07-10 12:27:18 +05:30
parent 08919e51bb
commit 2dad372e75
12 changed files with 150 additions and 3239 deletions

View File

@@ -20,16 +20,16 @@ import { proto } from '../../WAMessage/WAMessage'
export default class WhatsAppWebMessages extends WhatsAppWebBase {
/**
* Send a read receipt to the given ID for a certain message
* @param {string} jid the ID of the person/group whose message you want to mark read
* @param {string} [messageID] optionally, the message ID
* @param jid the ID of the person/group whose message you want to mark read
* @param messageID optionally, the message ID
* @param type whether to read or unread the message
*/
async sendReadReceipt(jid: string, messageID?: string, type: 'read' | 'unread' = 'read') {
const attributes = {
jid: jid,
count: messageID ? '1' : null,
count: type === 'read' ? '1' : '-2',
index: messageID,
owner: 'false',
type: type==='unread' ? 'false' : null
owner: messageID ? 'false' : null
}
return this.setQuery ([['read', attributes, null]])
}

View File

@@ -4,13 +4,11 @@ import * as fs from 'fs'
import * as assert from 'assert'
import { decodeMediaMessage, validateJIDForSending } from './Utils'
import { promiseTimeout } from '../WAConnection/Utils'
import { promiseTimeout, createTimeout } from '../WAConnection/Utils'
require ('dotenv').config () // dotenv to load test jid
const testJid = process.env.TEST_JID || '1234@s.whatsapp.net' // set TEST_JID=xyz@s.whatsapp.net in a .env file in the root directory
const createTimeout = (timeout) => new Promise(resolve => setTimeout(resolve, timeout))
async function sendAndRetreiveMessage(client: WAClient, content, type: MessageType, options: MessageOptions = {}) {
const response = await client.sendMessage(testJid, content, type, options)
assert.strictEqual(response.status, 200)