feat: add readMessages function

This commit is contained in:
Adhiraj Singh
2022-04-06 09:30:32 +05:30
parent 6d4fc87169
commit 5aa64f2c39
3 changed files with 44 additions and 10 deletions

View File

@@ -521,16 +521,19 @@ await sock.sendMessage('1234@s.whatsapp.net', { forward: msg }) // WA forward th
## Reading Messages
A set of message IDs must be explicitly marked read now.
Cannot mark an entire "chat" read as it were with Baileys Web.
A set of message keys must be explicitly marked read now.
In multi-device, you cannot mark an entire "chat" read as it were with Baileys Web.
This does mean you have to keep track of unread messages.
``` ts
const id = '1234-123@g.us'
const messageID = 'AHASHH123123AHGA' // id of the message you want to read
const participant = '912121232@s.whatsapp.net' // the ID of the user that sent the message (undefined for individual chats)
await sock.sendReadReceipt(id, participant, [messageID])
``` ts
const key = {
remoteJid: '1234-123@g.us',
id: 'AHASHH123123AHGA', // id of the message you want to read
participant: '912121232@s.whatsapp.net' // the ID of the user that sent the message (undefined for individual chats)
}
// pass to readMessages function
// can pass multiple keys to read multiple messages as well
await sock.readMessages([key])
```
The message ID is the unique identifier of the message that you are marking as read. On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.