Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with using BuildHistorySync to get on demand chat history #759

Open
kavyald opened this issue Feb 27, 2025 · 0 comments
Open

Problem with using BuildHistorySync to get on demand chat history #759

kavyald opened this issue Feb 27, 2025 · 0 comments

Comments

@kavyald
Copy link

kavyald commented Feb 27, 2025

Trying to get on demand history for a chat. The log shows that the history sync request is being sent. However, the historysync event handler is not receiving any events. Has anyone been able to successfully call BuildHistorySyncRequest? Am I missing something?

Here is a snippet of code that builds and sends the request using SendMessage.

// Parse the chat JID
chatJID, err := types.ParseJID(req.Chat)
if err != nil {
	s.Respond(w, r, http.StatusBadRequest, errors.New("Invalid chat JID"))
	return
}

// Create message info for the history sync request
msgInfo := &types.MessageInfo{
	ID: req.MessageID,
	MessageSource: types.MessageSource{
		Chat:     chatJID,
		IsFromMe: req.IsFromMe,
	},
	Timestamp: time.UnixMilli(req.Timestamp),
}

// Build the history sync request
historyMsg := clientPointer[userid].BuildHistorySyncRequest(msgInfo, req.MessageCount)
// Send the history sync request and wait for the response
_, err = clientPointer[userid].SendMessage(context.Background(), chatJID, historyMsg, whatsmeow.SendRequestExtra{Peer: true})
if err != nil {
	s.Respond(w, r, http.StatusInternalServerError, fmt.Errorf("Failed to send history sync request: %v", err))
	return
}

response := map[string]interface{}{
	"Details": "History sync request sent successfully",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant