Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
refactor(engine): drop unused selfJid from mapBaileysGroupInfo; tidy mapper
rmyndharisfb4b249358e8
diff --git a/src/engine/adapters/baileys-group-mapper.spec.ts b/src/engine/adapters/baileys-group-mapper.spec.tsindex be3cbe737..12a1bc2bc 100644--- a/src/engine/adapters/baileys-group-mapper.spec.ts+++ b/src/engine/adapters/baileys-group-mapper.spec.ts@@ -33,6 +33,11 @@ describe('mapBaileysGroup', () => {expect(mapBaileysGroup(meta(), '[email protected]').isAdmin).toBe(false);});+ it('isAdmin is true when self is a plain admin', () => {+ const m = meta({ participants: [{ id: '[email protected]', admin: 'admin' }] });+ expect(mapBaileysGroup(m, '[email protected]').isAdmin).toBe(true);+ });+it('carries the linked community parent when present', () => {expect(mapBaileysGroup(meta({ linkedParent: '[email protected]' }), '[email protected]').linkedParentJID).toBe('[email protected]');});@@ -40,7 +45,7 @@ describe('mapBaileysGroup', () => {describe('mapBaileysGroupInfo', () => {it('maps full info incl. participants admin/superadmin', () => {- const info = mapBaileysGroupInfo(meta({ announce: true }), '[email protected]');+ const info = mapBaileysGroupInfo(meta({ announce: true }));expect(info.id).toBe('[email protected]');expect(info.name).toBe('My Group');expect(info.description).toBe('a description');diff --git a/src/engine/adapters/baileys-group-mapper.ts b/src/engine/adapters/baileys-group-mapper.tsindex 53227661b..138b32eb5 100644--- a/src/engine/adapters/baileys-group-mapper.ts+++ b/src/engine/adapters/baileys-group-mapper.ts@@ -23,12 +23,11 @@ export function mapBaileysGroup(metadata: GroupMetadata, selfJid: string): Group}/** Map a Baileys GroupMetadata to the neutral {@link GroupInfo} (full participant list). */-// eslint-disable-next-line @typescript-eslint/no-unused-vars-export function mapBaileysGroupInfo(metadata: GroupMetadata, selfJid: string): GroupInfo {+export function mapBaileysGroupInfo(metadata: GroupMetadata): GroupInfo {const participants: GroupParticipant[] = metadata.participants.map(p => ({id: p.id,number: userPart(p.id),- name: p.name ?? undefined,+ name: p.name,isAdmin: p.admin === 'admin' || p.admin === 'superadmin',isSuperAdmin: p.admin === 'superadmin',}));