Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(baileys): drop picture-change markers from contact profilePicUrl
Yudhi Armyndharis5d36d55638cd
diff --git a/src/engine/adapters/baileys-session-store.spec.ts b/src/engine/adapters/baileys-session-store.spec.tsindex 8161b3b76..5ac26f525 100644--- a/src/engine/adapters/baileys-session-store.spec.ts+++ b/src/engine/adapters/baileys-session-store.spec.ts@@ -90,6 +90,15 @@ describe('BaileysSessionStore', () => {expect(store.listContacts()).toHaveLength(1);});+ it('reports no profilePicUrl for the picture-change markers Baileys stores in imgUrl', () => {+ // A `picture` notification arrives as contacts.update with imgUrl 'changed' or 'removed', not a URL.+ store.upsertContacts([{ id: '[email protected]', notify: 'Al', imgUrl: 'http://p/x.jpg' }]);+ store.upsertContacts([{ id: '[email protected]', imgUrl: 'changed' }]);+ store.upsertContacts([{ id: '[email protected]', notify: 'Bo', imgUrl: 'removed' }]);+ expect(store.findContact('[email protected]')?.profilePicUrl).toBeUndefined();+ expect(store.findContact('[email protected]')?.profilePicUrl).toBeUndefined();+ });+it('does not let a later history-sync row wipe a saved name with undefined', () => {// Baileys history contacts always include `name: displayName || name || username || undefined`.// Spreading that onto an address-book upsert that already had a name used to clear it.diff --git a/src/engine/adapters/baileys-session-store.ts b/src/engine/adapters/baileys-session-store.tsindex 1157dcfef..a14360176 100644--- a/src/engine/adapters/baileys-session-store.ts+++ b/src/engine/adapters/baileys-session-store.ts@@ -763,7 +763,8 @@ export class BaileysSessionStore {// whatsapp-web.js reports honestly from the Contact model.isMyContact: Boolean(c.name),isBlocked: false, // best-effort: blocklist state is not tracked in this slice- profilePicUrl: c.imgUrl ?? undefined,+ // A `picture` notification stores the marker 'changed' or 'removed' in imgUrl, not a URL.+ profilePicUrl: c.imgUrl && /^https?:\/\//i.test(c.imgUrl) ? c.imgUrl : undefined,};}