Skip to content

feat: SSE pub/sub stream, resolve-contacts endpoint, and LID phone number fix#191

Open
Stupidoodle wants to merge 2 commits intolharries:mainfrom
Stupidoodle:feat/sse-pubsub-and-resolve-contacts
Open

feat: SSE pub/sub stream, resolve-contacts endpoint, and LID phone number fix#191
Stupidoodle wants to merge 2 commits intolharries:mainfrom
Stupidoodle:feat/sse-pubsub-and-resolve-contacts

Conversation

@Stupidoodle
Copy link
Copy Markdown

Summary

  • SSE pub/sub stream (GET /api/stream): Real-time broadcast of all WhatsApp events (messages, receipts, typing, presence) via Server-Sent Events. Multiple subscribers supported. Enables event-driven integrations without polling — just curl -N http://localhost:8080/api/stream to debug.

  • Resolve contacts (POST /api/resolve-contacts): Bulk-resolves LID contact names. LID-based contacts (WhatsApp's privacy-obfuscated IDs) are stored with numeric-only names in the DB. This endpoint looks up real names from the WhatsApp contact store and persists them. Fixes the root cause of search_contacts returning no results for contacts stored as LIDs. Collects all unresolved JIDs before closing the DB cursor to avoid SQLite locking delays (~5s per write).

  • LID phone number fix in search_contacts: For @lid contacts, shows the real phone number by joining against whatsmeow_lid_map instead of the meaningless LID numeric part.

Test plan

  • Connect SSE stream: curl -N http://localhost:8080/api/stream — should receive events as messages arrive
  • Call POST /api/resolve-contacts — should return {"resolved": N, ...} and update LID contact names in DB
  • Search for a contact stored as LID: search_contacts("name") should find them with real phone number

🤖 Generated with Claude Code

Stupidoodle and others added 2 commits March 23, 2026 14:35
…erver scaffold

Go bridge (whatsapp-bridge/main.go):
- Update whatsmeow to latest, fix all context.Context API changes
- Add stealth mode: no auto read receipts, no auto presence
- Add events table for receipts, typing indicators
- Add REST endpoints: /api/mark-read, /api/typing, /api/presence, /api/resync
- Store sent messages at send time (fix LID echo issue)
- Fix audio filename collisions (prepend message ID)
- Fix contact name resolution for LID-based JIDs (PushName/BusinessName fallbacks)
- Filter self-receipts from events table

Python MCP server (whatsapp-mcp-server/):
- Add tools: get_chat_log, wait_for_reply, send_and_check, transcribe_audio
- Add stealth tools: get_events, mark_read, send_typing, set_presence
- Add resync_chats tool
- Fix wait_for_reply: rolling grace period, manual activity detection
- Add openai and python-dotenv dependencies

DM skill templates (templates/):
- Full autonomous DM skill with /dm slash command
- Protocol files: loop, reconnaissance, planning, resume
- Template files: identity, target, history, strategy, memory
- Setup script (dm-setup.sh) for one-command project creation
- Pre-configured .mcp.json and settings.local.json

Channel server scaffold (whatsapp-channel/):
- Bun project initialized with MCP SDK and zod
- Placeholder for event-driven channel implementation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…e number fix

- Add GET /api/stream SSE endpoint that broadcasts all WhatsApp events
  (messages, receipts, presence) to connected subscribers in real-time.
  Enables event-driven integrations without polling.

- Add POST /api/resolve-contacts endpoint that bulk-resolves LID contact
  names. Fixes the issue where LID-based contacts show as numeric IDs
  instead of real names. Collects unresolved JIDs before closing the DB
  cursor to avoid SQLite locking issues during writes.

- Fix search_contacts to show real phone numbers for LID contacts by
  joining against whatsmeow_lid_map table. Previously showed the raw
  LID numeric part as "phone_number" which was misleading.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant