mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:40:44 +00:00
refactor: generalize conversation id labels
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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/],
|
||||
|
||||
Reference in New Issue
Block a user