Skip to content

feat(message): opt-in deep chat history (deep=true) (#347)#371

Merged
rmyndharis merged 1 commit into
mainfrom
feat/deep-chat-history
Jun 20, 2026
Merged

feat(message): opt-in deep chat history (deep=true) (#347)#371
rmyndharis merged 1 commit into
mainfrom
feat/deep-chat-history

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

Closes #347.

Problem

GET /sessions/:id/messages/:chatId/history was clamped to 100 messages max per request. As the reporter found, that ceiling is OpenWA's own — not a WhatsApp limit. The whatsapp-web.js engine drives WhatsApp Web's "load earlier messages" mechanism, so it can reach much further back; we were the bottleneck.

Change

Add an opt-in deep=true query parameter:

  • Raises the limit ceiling from 100 → 2000 for that request.
  • Metadata-only: includeMedia is ignored in deep mode — downloading base64 for up to 2000 messages would be an enormous, slow payload. Fetch media per-message separately.
  • Default path unchanged: default 50, max 100, media as requested.
  • Baileys has no history sync, so the endpoint still returns 501 there regardless of deep (documented).

Tests (TDD, watched fail first)

Added 4 cases to message.service.spec.ts: deep allows >100, deep clamps to 2000, deep forces media off, and a regression guard that non-deep still clamps to 100.

  • npx jest932/932 pass (86 suites)
  • npm run build + eslint clean

Docs

Updated docs/examples/chat-history-limits.md (which already tracked this as #347) to document deep=true, the 2000 ceiling, the metadata-only behavior, the rate-limit caveat, and the Baileys 501.

The live history endpoint was capped at 100 messages per request — OpenWA's
own bound, not a WhatsApp limit, since whatsapp-web.js can load earlier
messages on demand. Add a deep=true query that raises the ceiling to 2000 for
reaching further back. Deep mode is metadata-only (ignores includeMedia, since
base64 for up to 2000 messages would be an enormous payload). Default path
unchanged (default 50, max 100). Baileys still returns 501 (no history sync).
@rmyndharis rmyndharis merged commit 20726df into main Jun 20, 2026
5 checks passed
@rmyndharis rmyndharis deleted the feat/deep-chat-history branch June 20, 2026 01:56
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

Successfully merging this pull request may close these issues.

[Bug/Feature]: Unable to get full chat history

1 participant