Fix: fetchMessageHistory con evento SSE y logs de debug
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m9s

- Agregar logs detallados en /api/debug/history/fetch para diagnosticar
- Emitir evento SSE 'history.synced' cuando llegan mensajes del historial
- Frontend ahora escucha el evento SSE en vez de timeout fijo de 3 segundos
- Agregar script y documentación para referencia de Baileys message history
This commit is contained in:
2025-12-04 12:33:22 -06:00
parent a9e786a8bd
commit 32f66c8fe0
7 changed files with 2004 additions and 10 deletions

View File

@@ -8,6 +8,7 @@ export interface RealtimeEvents {
'message.status': (data: { instanceId: string; messageId: string; status: string }) => void
'instance.status': (data: { instanceId: string; status: string; phoneNumber?: string }) => void
'instance.qr': (data: { instanceId: string; qr: string; qrDataUrl: string }) => void
'history.synced': (data: { instanceId: string; chatsCount: number; contactsCount: number; messagesCount: number; syncType: any }) => void
}
export const useRealtime = () => {
@@ -49,11 +50,12 @@ export const useRealtime = () => {
// Listen for specific event types
const eventTypes = [
'message.received',
'message.sent',
'message.sent',
'message.status',
'instance.status',
'instance.qr',
'instance.pairing'
'instance.pairing',
'history.synced'
]
eventTypes.forEach(eventType => {