Skip to content

fix: bind API to localhost and update whatsmeow#174

Open
binnybansal82 wants to merge 16 commits intolharries:mainfrom
binnybansal82:main
Open

fix: bind API to localhost and update whatsmeow#174
binnybansal82 wants to merge 16 commits intolharries:mainfrom
binnybansal82:main

Conversation

@binnybansal82
Copy link
Copy Markdown

Summary

  • Bind the REST API server to 127.0.0.1:8080 instead of :8080 to prevent access from other machines on the network
  • Update whatsmeow and all Go dependencies to fix client rejection by WhatsApp servers (405 error due to outdated client version)
  • Adapt API calls to pass context.Context as required by the new whatsmeow API

Test plan

  • Verify the bridge starts and connects to WhatsApp successfully
  • Verify messages can be sent and received through the MCP server
  • Verify media download still works with the updated API

🤖 Generated with Claude Code

BB and others added 16 commits March 1, 2026 13:53
Prevents the HTTP server from accepting connections from other machines
on the network, reducing the attack surface.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous whatsmeow version was rejected by WhatsApp servers (405).
Updated to latest version and adapted API calls to pass context.Context
as now required by the new whatsmeow API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Identifies chats needing attention: those where someone else sent the
last message, and those where I promised to follow up (e.g. "I'll get
back to you"). Includes recent message context and triggers calendar
reminders for deferred items.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Teaches Claude how to identify chats needing attention using existing
MCP tools, without adding business logic to the server. Includes
deferred reply detection and auto-calendar reminder instructions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Calls requestHistorySync when the bridge connects or reconnects
(e.g. after laptop wake), backfilling any messages missed while offline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Calls GetAllContacts on each connect event to populate chat names
in the DB. Skips locked ID (@lid) contacts. Updates 2598 contacts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Track chat lock state in the DB via WhatsApp app state events.
Resolves LID JIDs to phone-based JIDs and syncs all lock states
on startup via full app state fetch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add efficient single-query tool that returns chats with N context messages
each, reducing the "awaiting reply" workflow from 14+ MCP calls to 1-2.
Also add locked chat exclusion (chats.locked = 0) to list_chats,
list_messages, search_contacts, and get_contact_chats.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add "will let you know", rescheduling promises ("can we meet",
"how about [day]"), and general commitments ("I'll send", "let me
find") to deferred detection. Mark Step 2 as mandatory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Restores the requestHistorySync call on Connected event that was
accidentally reverted in dc03042. This backfills messages missed
while the bridge was offline/sleeping.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The old requestHistorySync passed nil to BuildHistorySyncRequest,
causing a nil pointer crash (why it was reverted). Rewritten to:
- Query DB for chats with <20 stored messages
- Find oldest message per chat
- Request 50 older messages via SendPeerMessage
- Rate limit requests to avoid flooding
- Include locked chats (lock is for display filtering, not sync)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When list_messages is called with a specific chat_jid, skip the
locked filter since it's an explicit request. Broad queries still
exclude locked chats.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WhatsApp returns @lid (Linked Identity) JIDs in history sync responses,
causing messages to be stored under JIDs that don't match the live chat.
This resolves @lid to phone-based @s.whatsapp.net JIDs using the
whatsmeow LID store before storing, and adds a startup migration to
clean up any previously stored @lid data.

Co-Authored-By: Claude Opus 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