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.38k stars 3.67k forks source link

Message ack events timestamps always the same #1106

Closed caiokawasaki closed 2 years ago

caiokawasaki commented 2 years ago

Reproduction steps

Steps to reproduce the behavior:

  1. Send a message
  2. Wait for ack events

Expected behavior/Relevant code

I sent a message to a number, I noticed that the ack events are always coming with the same timestamp, is this correct?

Here are some events of the same message that were performed 1 minute apart:

Ack 1:

const messageAck = {
  mediaKey: undefined,
  id: {
    fromMe: true,
    remote: 'xxxxx@c.us',
    id: 'MESSAGE_ID',
    _serialized: 'true_xxxxx@c.us_MESSAGE_ID'
  },
  ack: 1,
  hasMedia: false,
  body: 'Como você está 3?',
  type: 'chat',
  timestamp: 1642104555,
  from: 'yyyyy@c.us',
  to: 'xxxxx@c.us',
  author: undefined,
  deviceType: 'android',
  isForwarded: false,
  forwardingScore: 0,
  isStatus: false,
  isStarred: false,
  broadcast: undefined,
  fromMe: true,
  hasQuotedMsg: false,
  location: undefined,
  vCards: [],
  inviteV4: undefined,
  mentionedIds: [],
  orderId: undefined,
  token: undefined,
  links: []
}

Ack 2:

const messageAck = {
  mediaKey: undefined,
  id: {
    fromMe: true,
    remote: 'xxxxx@c.us',
    id: 'MESSAGE_ID',
    _serialized: 'true_xxxxx@c.us_MESSAGE_ID'
  },
  ack: 2,
  hasMedia: false,
  body: 'Como você está 3?',
  type: 'chat',
  timestamp: 1642104555,
  from: 'yyyyy@c.us',
  to: 'xxxxx@c.us',
  author: undefined,
  deviceType: 'android',
  isForwarded: false,
  forwardingScore: 0,
  isStatus: false,
  isStarred: false,
  broadcast: undefined,
  fromMe: true,
  hasQuotedMsg: false,
  location: undefined,
  vCards: [],
  inviteV4: undefined,
  mentionedIds: [],
  orderId: undefined,
  token: undefined,
  links: []
}

Ack 3:

const messageAck = {
  mediaKey: undefined,
  id: {
    fromMe: true,
    remote: 'xxxxx@c.us',
    id: 'MESSAGE_ID',
    _serialized: 'true_xxxxx@c.us_MESSAGE_ID'
  },
  ack: 3,
  hasMedia: false,
  body: 'Como você está 3?',
  type: 'chat',
  timestamp: 1642104555,
  from: 'yyyyy@c.us',
  to: 'xxxxx@c.us',
  author: undefined,
  deviceType: 'android',
  isForwarded: false,
  forwardingScore: 0,
  isStatus: false,
  isStarred: false,
  broadcast: undefined,
  fromMe: true,
  hasQuotedMsg: false,
  location: undefined,
  vCards: [],
  inviteV4: undefined,
  mentionedIds: [],
  orderId: undefined,
  token: undefined,
  links: []
}

Shouldn't the timestamp of the events be different? It seems that for both acks I'm getting the timestamp of the message and not the event itself.

Environment

WhatsApp

Library

Other

caiokawasaki commented 2 years ago

I got the status timestamps using the following method:

const ACK_DEVICE = 2
const ACK_READ = 3
const ACK_PLAYED = 4

const resolveStatusTimestamp = async message => {
    const info = await message.getInfo()

    switch (message.ack) {
        case ACK_DEVICE:
            return info['delivery'][0].t
        case ACK_READ:
            return info['read'][0].t
        case ACK_PLAYED:
            return info['played'][0].t
        default:
            return null
    }
}