Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): do not format a privacy id as a phone number
Yudhi Armyndharis3f44078f6667
diff --git a/dashboard/src/components/chats/GroupInfoDialog.tsx b/dashboard/src/components/chats/GroupInfoDialog.tsxindex ecb544f92..ed13d651a 100644--- a/dashboard/src/components/chats/GroupInfoDialog.tsx+++ b/dashboard/src/components/chats/GroupInfoDialog.tsx@@ -344,15 +344,17 @@ function GroupInfoDialog({ session, group, onClose, onRenamed }: GroupInfoDialog<ul className="group-info-list">{info.participants.map(p => {const own = isOwnAccount(p, session);- const label = own ? t('chats.you') : p.name || formatPhoneForDisplay(p.number) || p.number;+ // Formatted from the id, not from `number`: a privacy id (@lid) has digits too, and they are no phone.+ const phone = formatPhoneForDisplay(p.id);+ const label = own ? t('chats.you') : p.name || phone || p.number;return (<li key={p.id}><ChatAvatar kind="individual" /><span className="group-info-member"><bdi className="name">{label}</bdi>- {p.name && (+ {p.name && phone && (<bdi className="number" dir="ltr">- {formatPhoneForDisplay(p.number) ?? p.number}+ {phone}</bdi>)}</span>diff --git a/dashboard/src/pages/Chats.features.test.ts b/dashboard/src/pages/Chats.features.test.tsindex f169e8684..a57e45562 100644--- a/dashboard/src/pages/Chats.features.test.ts+++ b/dashboard/src/pages/Chats.features.test.ts@@ -72,6 +72,8 @@ let groupAdmin = true;let groupName = GROUP.name;let groupDescription = 'old description';let bobIsAdmin = false;+// When true, GROUP also lists a member WhatsApp knows by a privacy id only, which carries no phone number.+let groupHasLidMember = false;// When true, a membership write answers HTTP 200 with its participants refused in `results`, as the route does// for a batch WhatsApp turns down in part.let refuseMember = false;@@ -160,6 +162,9 @@ function installFetchStub(): void {participants: [{ id: `${SESSION.phone}@c.us`, number: SESSION.phone, isAdmin: groupAdmin, isSuperAdmin: false },{ id: '[email protected]', number: '15550002222', name: 'Bob', isAdmin: bobIsAdmin, isSuperAdmin: false },+ ...(groupHasLidMember+ ? [{ id: '262813461250071@lid', number: '262813461250071', isAdmin: false, isSuperAdmin: false }]+ : []),],}),);@@ -283,6 +288,7 @@ afterEach(async () => {groupName = GROUP.name;groupDescription = 'old description';bobIsAdmin = false;+ groupHasLidMember = false;refuseMember = false;blockedIds = [];window.sessionStorage.setItem('openwa_user_role', 'admin');@@ -570,6 +576,20 @@ test('a group picture saved in the group dialog replaces the one on the sidebar}});+test('a member known only by a privacy id is not shown as a phone number', async () => {+ const { fireEvent, within } = rtl;+ listGroup = true;+ groupHasLidMember = true;+ renderPage();+ const dialog = await openGroupInfo();+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));++ const names = Array.from(dialog.querySelectorAll('.group-info-member .name')).map(name => name.textContent);+ // The digits of a privacy id are no phone number, so they are shown as they are and never grouped like one.+ assert.deepEqual(names, ['You', 'Bob', '262813461250071']);+ assert.ok(!(dialog.textContent ?? '').includes('+262'), 'a privacy id was formatted as an international number');+});+test('a participant the gateway refuses is reported although the write answered 200', async () => {const { screen, fireEvent, waitFor, within } = rtl;listGroup = true;