fix: Message.getInfo (#2574)

* module fixed + improved modules retrieving

* wait for msg data to be updated

* added random sleep value between 1100-1200 ms

* added check for msg is sent by current user

* node 13 compatible

* docs fixed

* msg.fromMe fixed

* timestamp calculation fixed

* window.injectToFunction clarifications
This commit is contained in:
alechkos 2023-11-24 12:18:18 +02:00 • committed by GitHub
commit 7ff9c9807b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -534,15 +534,20 @@ class Message extends Base {
*/
/**
* Get information about message delivery status. May return null if the message does not exist or is not sent by you.
* Get information about message delivery status.
* May return null if the message does not exist or is not sent by you.
* @returns {Promise<?MessageInfo>}
*/
async getInfo() {
const info = await this.client.pupPage.evaluate(async (msgId) => {
const msg = window.Store.Msg.get(msgId);
if (!msg) return null;
if (!msg || !msg.id.fromMe) return null;
return await window.Store.MessageInfo.sendQueryMsgInfo(msg.id);
return new Promise((resolve) => {
setTimeout(async () => {
resolve(await window.Store.getMsgInfo(msg.id));
}, (Date.now() - msg.t * 1000 < 1250) && Math.floor(Math.random() * (1200 - 1100 + 1)) + 1100 || 0);
});
}, this.id._serialized);
return info;