refactor: generalize conversation id labels

This commit is contained in:
Peter Steinberger
2026-04-22 05:53:04 +01:00
parent e20a5eeddb
commit 6639bbbc2e
3 changed files with 11 additions and 7 deletions

View File

@@ -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",

View File

@@ -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;

View File

@@ -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/],