From f9f836eba47de18ab79eb1eed77d76cd03551e28 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 22 Apr 2026 12:32:08 -0700 Subject: [PATCH] fix(hooks): normalize thread ownership slack id casing --- extensions/thread-ownership/index.test.ts | 12 ++++++------ extensions/thread-ownership/index.ts | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/extensions/thread-ownership/index.test.ts b/extensions/thread-ownership/index.test.ts index 21f97fdce35..c29e7072042 100644 --- a/extensions/thread-ownership/index.test.ts +++ b/extensions/thread-ownership/index.test.ts @@ -132,7 +132,7 @@ describe("thread-ownership plugin", () => { { content: "hello", replyToId: "1234.5678", - to: "channel:C123", + to: "channel:c123", }, { channelId: "slack", conversationId: "" }, ); @@ -148,7 +148,7 @@ describe("thread-ownership plugin", () => { }); it("canonicalizes configured ab-test channel allowlists before matching", async () => { - api.pluginConfig = { abTestChannels: ["channel:C123"] }; + api.pluginConfig = { abTestChannels: ["channel:c123"] }; register.register(api as unknown as OpenClawPluginApi); vi.mocked(globalThis.fetch).mockResolvedValue( new Response(JSON.stringify({ owner: "test-agent" }), { status: 200 }), @@ -158,7 +158,7 @@ describe("thread-ownership plugin", () => { { content: "hello", replyToId: "1234.5678", - to: "channel:C123", + to: "channel:c123", }, { channelId: "slack", conversationId: "" }, ); @@ -227,7 +227,7 @@ describe("thread-ownership plugin", () => { { content: "Hey @TestBot help me", threadId: "9999.0002", - metadata: { channelId: "channel:C456" }, + metadata: { channelId: "channel:c456" }, }, { channelId: "slack", conversationId: "C456" }, ); @@ -250,7 +250,7 @@ describe("thread-ownership plugin", () => { { content: "Hey @TestBot help me", threadId: "9999.0003", - metadata: { channelId: "channel:C456" }, + metadata: { channelId: "channel:c456" }, }, { channelId: "slack", conversationId: "" }, ); @@ -259,7 +259,7 @@ describe("thread-ownership plugin", () => { { content: "Sure!", replyToId: "9999.0003", - to: "C456", + to: "c456", }, { channelId: "slack", conversationId: "C456" }, ); diff --git a/extensions/thread-ownership/index.ts b/extensions/thread-ownership/index.ts index 1efa59ed9c7..5b9d9bd71d8 100644 --- a/extensions/thread-ownership/index.ts +++ b/extensions/thread-ownership/index.ts @@ -31,7 +31,8 @@ function resolveSlackConversationId(value: unknown): string { } const trimmed = raw.trim(); const match = /^(?:slack:)?channel:(.+)$/i.exec(trimmed); - return match?.[1]?.trim() || trimmed; + const resolved = match?.[1]?.trim() || trimmed; + return /^[CDGUW][A-Z0-9]+$/i.test(resolved) ? resolved.toUpperCase() : resolved; } function cleanExpiredMentions(): void {