tulir / whatsmeow

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

Requesting historical messages fail #654

Open jambazishvili opened 2 months ago

jambazishvili commented 2 months ago

I try to retrieve messages from the group but no response is returned or event handler does not receive anything. The setup looks like this:

  1. Retrieve the device from store.
  2. Connect.
  3. Add event listeners (I am not sure if it is required, but using for other stuff)
  4. Build history sync request.
  5. Nothing happens

Below is the code:

WAClient := whatsmeow.NewClient(WADevice, logger)
WAClient.AddEventHandler(...)
if err = WAClient.Connect(); err != nil {
  logger.Errorf("failed to resume device %s", WADevice)
}

// ---

messageInfo := types.MessageInfo{
MessageSource: types.MessageSource{
    Chat:     groupJID,  // xxx@g.us
    IsGroup:  true,
    IsFromMe: false,
},
ID:        "xxx",
Timestamp: time.Now(),
}
histRequest := WAClient.BuildHistorySyncRequest(&messageInfo, 10)
extra := whatsmeow.SendRequestExtra{Peer: true}
res, err := WAClient.SendMessage(context.Background(), groupJID, histRequest, extra)

Once the message is sent, it logs this:

10:20:20.265 [wa WARN] Failed to fetch prekey for xxx:23@s.whatsapp.net: invalid prekey in prekey response: prekey node doesn't contain ID tag
10:20:20.265 [wa WARN] Failed to fetch prekey for xxx:24@s.whatsapp.net: invalid prekey in prekey response: prekey node doesn't contain ID tag

In the event listener, I do not get anything, res also does not contain messages, just timing information. Can you please suggest how to debug or if visible what I am doing wrong?

DavidsonGomes commented 1 month ago

I have the same problem

ichabod-mo commented 2 weeks ago

same question