diff --git a/src/channels/conversation-label.test.ts b/src/channels/conversation-label.test.ts index 16ba4cd6356..9b2d1a48062 100644 --- a/src/channels/conversation-label.test.ts +++ b/src/channels/conversation-label.test.ts @@ -47,19 +47,19 @@ describe("resolveConversationLabel", () => { name: "does not append ids when the base already contains the id", ctx: { ChatType: "group", - GroupSubject: "Family id:123@g.us", - From: "whatsapp:group:123@g.us", + GroupSubject: "Family id:room-123@example", + From: "demo-channel:group:room-123@example", }, - expected: "Family id:123@g.us", + expected: "Family id:room-123@example", }, { - name: "appends ids for WhatsApp-like group ids when a subject exists", + name: "appends opaque address-like ids when a subject exists", ctx: { ChatType: "group", GroupSubject: "Family", - From: "whatsapp:group:123@g.us", + From: "demo-channel:group:room-123@example", }, - expected: "Family id:123@g.us", + expected: "Family id:room-123@example", }, ] satisfies Array<{ name: string; ctx: MsgContext; expected: string }>)( "$name", diff --git a/src/channels/conversation-label.ts b/src/channels/conversation-label.ts index d652dec5a8b..0c329e0d8ec 100644 --- a/src/channels/conversation-label.ts +++ b/src/channels/conversation-label.ts @@ -18,7 +18,7 @@ function shouldAppendId(id: string): boolean { if (/^[0-9]+$/.test(id)) { return true; } - if (id.includes("@g.us")) { + if (/^[^\s:@]+@[^\s:@]+$/.test(id)) { return true; } return false; diff --git a/src/secrets/channel-contract-surface-guardrails.test.ts b/src/secrets/channel-contract-surface-guardrails.test.ts index a61e4848198..8d36a305dcc 100644 --- a/src/secrets/channel-contract-surface-guardrails.test.ts +++ b/src/secrets/channel-contract-surface-guardrails.test.ts @@ -62,6 +62,10 @@ const CORE_SECRET_SURFACE_GUARDS = [ path: "src/config/sessions/group.ts", forbiddenPatterns: [/\bwhatsapp\b/, /@g\.us/], }, + { + path: "src/channels/conversation-label.ts", + forbiddenPatterns: [/@g\.us/], + }, { path: "src/channels/plugins/setup-promotion-helpers.ts", forbiddenPatterns: [/\btelegram\b/],