Skip to content

fix: add @lid format support and allowFrom wildcard handling#1

Closed
mneves75 wants to merge 2 commits intoopenclaw:mainfrom
mneves75:fix/lid-format-and-allowfrom-wildcard
Closed

fix: add @lid format support and allowFrom wildcard handling#1
mneves75 wants to merge 2 commits intoopenclaw:mainfrom
mneves75:fix/lid-format-and-allowfrom-wildcard

Conversation

@mneves75
Copy link
Contributor

Summary

This PR fixes two critical bugs that prevent the web relay from processing inbound messages on newer WhatsApp versions:

  1. LID format not recognized: WhatsApp now uses Linked ID (@lid) format for message senders instead of the traditional @s.whatsapp.net format. The current jidToE164() function silently drops these messages.

  2. Wildcard "*" in allowFrom doesn't work: The allowFrom: ["*"] configuration is documented to allow all senders, but the code performs an exact string match, so "*" never matches any phone number.


Bug 1: LID Format Not Supported

Problem

WhatsApp has transitioned to using Linked IDs (LID) for identifying users in newer API versions. Messages now arrive with JIDs in the format:

142326760485098@lid

Instead of the traditional format:

5561983297558@s.whatsapp.net

The current jidToE164() function in src/utils.ts only matches the @s.whatsapp.net format, causing all inbound messages from @lid JIDs to be silently dropped.

Solution

Updated jidToE164() to check for @lid format and use the existing reverse mapping files that warelay already creates in ~/.warelay/credentials/lid-mapping-*_reverse.json.


Bug 2: allowFrom Wildcard Not Working

Problem

The allowFrom configuration is documented to support "*" as a wildcard to allow messages from all senders. However, the implementation performs an exact string match:

if (!allowFrom.includes(from)) {  // Exact match only!

When allowFrom: ["*"] is configured, the check fails because "+556183297558" is not literally in ["*"].

Solution

Added a check for the wildcard before performing the exact match:

if (!allowFrom.includes("*") && !allowFrom.includes(from)) {

Testing

  1. LID Format Resolution: Messages from @lid JIDs are now correctly resolved to E.164 phone numbers
  2. allowFrom Wildcard: allowFrom: ["*"] now correctly allows all senders
  3. Backward Compatibility: Traditional @s.whatsapp.net JIDs and explicit phone number lists continue to work

Files Changed

File Change
src/utils.ts Add @lid format support to jidToE164()
src/auto-reply/reply.ts Add wildcard check in allowFrom validation

Breaking Changes

None. These changes are backward compatible.


Environment

  • warelay version: 1.1.0
  • Node.js version: v24.11.0
  • WhatsApp: Latest iOS/Android versions using LID format

conhecendoia and others added 2 commits November 26, 2025 12:43
- Add support for WhatsApp Linked ID (@lid) format in jidToE164()
- Use existing lid-mapping-*_reverse.json files for LID resolution
- Fix allowFrom wildcard '*' to actually allow all senders
- Maintain backward compatibility with @s.whatsapp.net format

Fixes issues where:
- Messages from newer WhatsApp versions are silently dropped
- allowFrom: ['*'] configuration doesn't work as documented
@steipete
Copy link
Contributor

Oh awesome, thank you for your help!

@steipete
Copy link
Contributor

I'll cherry-pick this and add tests + some more fixes.

@steipete steipete closed this Nov 26, 2025
@mneves75
Copy link
Contributor Author

You are welcome

@mneves75 mneves75 deleted the fix/lid-format-and-allowfrom-wildcard branch November 27, 2025 20:22
steipete pushed a commit that referenced this pull request Jan 10, 2026
* fix(signal): handle reactions inside dataMessage.reaction

Signal reactions can arrive in two formats:
1. envelope.reactionMessage (already handled)
2. envelope.dataMessage.reaction (now handled)

The signal-cli SSE events use the second format, which was being
misinterpreted as a message with attachments, leading to 'broken
media / attachments' errors.

Changes:
- Add reaction property to SignalDataMessage type
- Check both envelope.reactionMessage and dataMessage.reaction
- Improve body content detection to properly identify reaction-only messages
- Add test for dataMessage.reaction format

* fix(signal): reaction notifications work when account is phone number

When reactionNotifications mode is 'own', notifications would never fire
because resolveSignalReactionTarget() returned a UUID but
shouldEmitSignalReactionNotification() compared it against the account
phone number, which never matched.

The fix:
- Add optional 'phone' field to SignalReactionTarget type
- Extract phone number first in resolveSignalReactionTarget(), include
  it even when UUID is present
- In shouldEmitSignalReactionNotification() 'own' mode, check phone
  match first before falling back to UUID comparison

This ensures reactions to your own messages are properly detected when
the Signal account is configured as a phone number and the reaction
event contains both targetAuthor (phone) and targetAuthorUuid.

* fix(signal): include phone in reaction target for own-mode matching

When targetAuthorUuid is present, also store targetAuthor phone number
in the reaction target. This allows own-mode reaction notifications to
match when comparing account phone against UUID-based targets.
@morganknutson morganknutson mentioned this pull request Jan 27, 2026
Havoc420didi pushed a commit to Havoc420didi/moltbot that referenced this pull request Jan 28, 2026
@CompassHXM
Copy link

Addressed all 3 review comments:

  1. ✅ Removed Git Workflow section (internal guideline)
  2. ✅ Removed config backup mention (unclear mechanism)
  3. ✅ Removed source directory path, using <source-directory> placeholder

Please check the updated diff!

@Jah-yee
Copy link

Jah-yee commented Mar 4, 2026

Hey @xiaoyaner0201 @Octane0411 @Diaspar4u - if you're building plugins/extensions, we just launched OpenClawHQ to help organize the plugin ecosystem!

Ship > Talk! 🦞

@Sykeya Sykeya mentioned this pull request Mar 4, 2026
@sungdark
Copy link

sungdark commented Mar 7, 2026

test comment from bot

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.