whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

feat: get message by id

Open pedroslopez opened this issue 3 years ago • 13 comments

pedroslopez avatar Aug 21 '21 07:08 pedroslopez

did some tests

purpshell avatar Aug 29 '21 23:08 purpshell

For reference: Starts failing on 20 hours (70971 seconds)

the "message" that got success was 18 days ago, and the type is: 'e2e_notification'

messageId, IfGotTheMessage, timeSpent, timeDiference image

tuyuribr avatar Aug 29 '21 23:08 tuyuribr

For reference: Starts failing on 20 hours (70971 seconds)

the "message" that got success was 18 days ago, and the type is: 'e2e_notification'

messageId, IfGotTheMessage, timeSpent, timeDiference image

that's some extensive testing

purpshell avatar Aug 30 '21 22:08 purpshell

It's failing randomly, if someone notices a patern please help us (got messageId from msgstore.db select timestamp,key_remote_jid,key_id,key_from_me,media_wa_type from messages order by timestamp desc limit 1000 )

tests.csv

tuyuribr avatar Aug 30 '21 23:08 tuyuribr

When trying to get an old message, I get null. And this message is really not deleted.

image

akaa0 avatar Sep 23 '21 18:09 akaa0

When trying to get an old message, I get null. And this message is really not deleted.

image

Does this happen always? There is also a chance that the chat has been cleared etc.. Make sure you can search for it via the search bar...

purpshell avatar Sep 26 '21 19:09 purpshell

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 30 '21 06:10 stale[bot]

Any chance this works on MD?

ReniDelonzek avatar Nov 28 '21 16:11 ReniDelonzek

Any chance this works on MD?

Haha, no. This would only fetch messages stored in the storage of a linked device. No fetching from phone

purpshell avatar Dec 21 '21 10:12 purpshell

I need this feature please merge it as soon as possible

hanumanjiblog avatar Jan 27 '22 06:01 hanumanjiblog

What about

        const msg = await this.pupPage.evaluate(async messageId => {
            let msg = window.Store.Msg.get(messageId);
            if(msg) return window.WWebJS.getMessageModel(msg);
            const params = messageId.split('_');
            if(params.length !== 3) throw new Error('Invalid serialized message id specified');

            const chatId = params[1];
            const chat = window.Store.Chat.get(chatId);
            while (chat.msgs._models.find(msg => msg.id._serialized === messageId)) {
                await chat.loadEarlierMsgs();
            }
            msg = window.Store.Msg.get(messageId);
            if(msg) return window.WWebJS.getMessageModel(msg);
        }, messageId);

        if(msg) return new Message(this, msg);
        return null;
    }

@pedroslopez This way seems working

shirser121 avatar Feb 05 '22 22:02 shirser121

@pedroslopez is there any estimation for merging this PR?

roigreenberg avatar Apr 17 '22 01:04 roigreenberg

@pedroslopez this PR is planned to merge? or what workaround you can recommend me?

herduin avatar Jun 25 '22 15:06 herduin

Closing after merge of #1634

shirser121 avatar Aug 07 '23 20:08 shirser121