fix(whatsapp): resolve LID sender IDs to phone numbers in bridge message payload
WhatsApp has migrated to Linked Identity Device (LID) format for user IDs (e.g. 244645917392975@lid instead of 18505551234@s.whatsapp.net). The bridge already resolves LIDs to phone numbers for its own allowlist check via buildLidMap(), but the senderId field in the message payload sent to the gateway still contained the raw LID. This caused the gateway's WHATSAPP_ALLOWED_USERS check to reject all messages as unauthorized, since the LID numbers don't match the phone numbers in the allowlist. Fix: resolve LID → phone in the senderId, senderName, and chatName fields of the event payload before sending to the gateway, using the existing lidToPhone mapping.
This commit is contained in:
parent
019950560d
commit
c0d694a492
1 changed files with 10 additions and 3 deletions
|
|
@ -510,12 +510,19 @@ async function startSocket() {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Resolve LID → phone for the senderId so the gateway can match
|
||||
// against phone-based allowlists (WHATSAPP_ALLOWED_USERS).
|
||||
const resolvedSenderId = lidToPhone[senderNumber]
|
||||
? (lidToPhone[senderNumber] + '@s.whatsapp.net')
|
||||
: senderId;
|
||||
const resolvedSenderNumber = lidToPhone[senderNumber] || senderNumber;
|
||||
|
||||
const event = {
|
||||
messageId: msg.key.id,
|
||||
chatId,
|
||||
senderId,
|
||||
senderName: msg.pushName || senderNumber,
|
||||
chatName: isGroup ? (chatId.split('@')[0]) : (msg.pushName || senderNumber),
|
||||
senderId: resolvedSenderId,
|
||||
senderName: msg.pushName || resolvedSenderNumber,
|
||||
chatName: isGroup ? (chatId.split('@')[0]) : (msg.pushName || resolvedSenderNumber),
|
||||
isGroup,
|
||||
body,
|
||||
hasMedia,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue