mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 01:53:21 +08:00
Fix WhatsApp group access when senders are opaque LIDs.
Resolve LID to phone aliases before allowlist and @mention checks so group prompts are not silently dropped after a working direct chat. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
7f1b9bd480
commit
d9edca4d5f
9 changed files with 472 additions and 203 deletions
|
|
@ -158,6 +158,7 @@ function createBridge({
|
|||
signal,
|
||||
logger,
|
||||
reactions,
|
||||
groupSessionScope = 'chat',
|
||||
} = {}) {
|
||||
return new TextHarnessBridge({
|
||||
descriptor: { key: 'test', label: 'Test', reactions },
|
||||
|
|
@ -166,6 +167,7 @@ function createBridge({
|
|||
state,
|
||||
signal,
|
||||
logger: logger ?? { warn() {}, error() {} },
|
||||
groupSessionScope,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
74
test/channels/whatsapp/whatsapp-identity.test.mjs
Normal file
74
test/channels/whatsapp/whatsapp-identity.test.mjs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
|
||||
import {
|
||||
enrichWhatsappInboundIdentities,
|
||||
isWhatsappLidJid,
|
||||
rememberWhatsappLidPnPairs,
|
||||
} from '../../../src/channels/whatsapp/whatsapp-identity.mjs';
|
||||
|
||||
describe('whatsapp-identity', () => {
|
||||
it('recognizes lid jids', () => {
|
||||
assert.equal(isWhatsappLidJid('91010910658657@lid'), true);
|
||||
assert.equal(isWhatsappLidJid('8618142387786@s.whatsapp.net'), false);
|
||||
});
|
||||
|
||||
it('remembers lid/pn pairs from message keys', () => {
|
||||
const cache = new Map();
|
||||
rememberWhatsappLidPnPairs(cache, {
|
||||
participant: '91010910658657@lid',
|
||||
participantAlt: '8618142387786@s.whatsapp.net',
|
||||
});
|
||||
assert.equal(cache.get('91010910658657'), '8618142387786@s.whatsapp.net');
|
||||
});
|
||||
|
||||
it('enriches group sender aliases and mentions from lid mapping', async () => {
|
||||
const cache = new Map();
|
||||
const socket = {
|
||||
signalRepository: {
|
||||
lidMapping: {
|
||||
async getPNForLID(lid) {
|
||||
if (lid === '91010910658657@lid') return '8618142387786@s.whatsapp.net';
|
||||
if (lid === '111222333444555@lid') return '8615601877957@s.whatsapp.net';
|
||||
return null;
|
||||
},
|
||||
async getLIDForPN(pn) {
|
||||
if (pn === '8615601877957@s.whatsapp.net') return '111222333444555@lid';
|
||||
return null;
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const raw = {
|
||||
key: {
|
||||
remoteJid: '120363429229984366@g.us',
|
||||
participant: '91010910658657@lid',
|
||||
id: 'msg-1',
|
||||
fromMe: false,
|
||||
},
|
||||
message: {
|
||||
extendedTextMessage: {
|
||||
text: '@bot hello',
|
||||
contextInfo: { mentionedJid: ['111222333444555@lid'] },
|
||||
},
|
||||
},
|
||||
};
|
||||
const normalized = {
|
||||
messageId: 'g:msg-1',
|
||||
providerMessageId: 'msg-1',
|
||||
senderId: '91010910658657@lid',
|
||||
senderAlternateId: '',
|
||||
kind: 'group',
|
||||
conversationId: '120363429229984366@g.us',
|
||||
content: '@bot hello',
|
||||
addressed: false,
|
||||
};
|
||||
const enriched = await enrichWhatsappInboundIdentities(normalized, raw, {
|
||||
accountJid: '8615601877957@s.whatsapp.net',
|
||||
socket,
|
||||
lidPnCache: cache,
|
||||
});
|
||||
assert.equal(enriched.addressed, true);
|
||||
assert.ok(enriched.senderAliasIds.includes('8618142387786@s.whatsapp.net'));
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue