pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.58k stars 3.72k forks source link

Bug: fetchMessage Function Does Not Update Message ACK Status Properly #2777

Open elhumbertoz opened 9 months ago

elhumbertoz commented 9 months ago

Is there an existing issue for this?

Describe the bug

When invoking the fetchMessagefunction in the whatsapp-web.js library to retrieve messages, it is observed that the ack property of the retrieved messages does not update correctly. The ack property should reflect the status of the message delivery confirmation, with numeric values according to the specification: ACK_ERROR: -1, ACK_PENDING: 0, ACK_SERVER: 1, ACK_DEVICE: 2, ACK_READ: 3, ACK_PLAYED: 4.

Expected behavior

We expect that when invoking fetchMessageand then marking the messages as read using the Chat.SendSeen function, the ack property of the messages updates correctly to ACK_READ (3) to reflect that they have been read.

Steps to Reproduce the Bug or Issue

  1. Receive a message from a user in a chat.
  2. Mark the chat as read using the Chat.SendSeen function.
  3. Retrieve the messages with the fetchMessagefunction.
  4. Check the value of the ackproperty of the retrieved messages.

Relevant Code

chat.sendSeen();
await chat.fetchMessages({limit: limit}).then(async(messages) => {
  messages = messages.filter(msg => msg.ack <= 2); //  It is not the ack property of the messages updated correctly to ACK_READ (3)

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

Linux, Phone Android, main whatsapp-web.js versión, Wathsapp: 2.2407.2

Additional context

No response

N0N4M3BNS commented 6 months ago

@elhumbertoz on your side still have the problem? because on my side, sometimes ACK is still not updated.

JohnSilver98 commented 1 month ago

Unfortunately I'm having the same problem, updating the read state only happens if I restart the script. I tried with message.reload(); as a method, but it doesn't even work. Reads state in local cache and not from server