Manage group metdata state in Baileys + Remove presence from Contact

This commit is contained in:
Adhiraj Singh
2020-12-03 13:16:37 +05:30
parent d4b453f0e5
commit 6d7dc4d9fe
7 changed files with 136 additions and 66 deletions

View File

@@ -30,13 +30,13 @@ export const makeConnection = () => {
return conn
}
export async function sendAndRetreiveMessage(conn: WAConnection, content, type: MessageType, options: MessageOptions = {}) {
const response = await conn.sendMessage(testJid, content, type, options)
const {messages} = await conn.loadMessages(testJid, 10)
export async function sendAndRetreiveMessage(conn: WAConnection, content, type: MessageType, options: MessageOptions = {}, recipientJid = testJid) {
const response = await conn.sendMessage(recipientJid, content, type, options)
const {messages} = await conn.loadMessages(recipientJid, 10)
const message = messages.find (m => m.key.id === response.key.id)
assert.ok(message)
const chat = conn.chats.get(testJid)
const chat = conn.chats.get(recipientJid)
assert.ok (chat.messages.get(GET_MESSAGE_ID(message.key)))
assert.ok (chat.t >= (unixTimestampSeconds()-5) )