tulir / whatsmeow

Go library for the WhatsApp web multidevice API
https://go.mau.fi/whatsmeow
Mozilla Public License 2.0
2.24k stars 418 forks source link

Error in some messages #235

Closed ferd1995 closed 1 year ago

ferd1995 commented 2 years ago

Some messages are not sent, because the log reports the following message

11:04:52.991 [Database ERROR] Failed to handle retry receipt for XXXXX@s.whatsapp.net/3EB00EB42154532069B4 from XXXXX@s.whatsapp.net: couldn't find message 3EB00EB42154532069B4

Any idea?

serenity-77 commented 2 years ago

Whatsmeow seems to cache the message before send to facilitate message retry in the future.

This maybe happen after you send a message and then restarted the connection, this will cause all previously cached message lost.

So before you send the message (waProto *Message) you need to store the message in persistent storage. And after that provide an implementation to client.GetMessageForRetry(requester, to types.JID, id types.MessageID) function to fetch the message that needs to be retried.

j-f-r commented 2 years ago

Thansk for the reply @Serenity-77 .

I found out where we need to overwrite GetMessageForRetry in the client and I have an idea of how to do it.

However, it seems we need the MessageID before sending the message in order to cache it and retrieve it using MessageID in GetMessageForRetry. Is it possible to have the ID before sending the message?

EDIT: Nevermind, we call whatsapp.GenerateMessageID() beforehand! I think we have the solution now!