fix(hooks): normalize thread ownership channel allowlists · openclaw/openclaw@ec75545
vincentkoc
·
2026-04-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,7 @@ describe("thread-ownership plugin", () => {
|
25 | 25 | for (const key of Object.keys(hooks)) { |
26 | 26 | delete hooks[key]; |
27 | 27 | } |
| 28 | +api.pluginConfig = {}; |
28 | 29 | |
29 | 30 | process.env.SLACK_FORWARDER_URL = "http://localhost:8750"; |
30 | 31 | process.env.SLACK_BOT_USER_ID = "U999"; |
@@ -146,6 +147,32 @@ describe("thread-ownership plugin", () => {
|
146 | 147 | ); |
147 | 148 | }); |
148 | 149 | |
| 150 | +it("canonicalizes configured ab-test channel allowlists before matching", async () => { |
| 151 | +api.pluginConfig = { abTestChannels: ["channel:C123"] }; |
| 152 | +register.register(api as unknown as OpenClawPluginApi); |
| 153 | +vi.mocked(globalThis.fetch).mockResolvedValue( |
| 154 | +new Response(JSON.stringify({ owner: "test-agent" }), { status: 200 }), |
| 155 | +); |
| 156 | + |
| 157 | +const result = await hooks.message_sending( |
| 158 | +{ |
| 159 | +content: "hello", |
| 160 | +replyToId: "1234.5678", |
| 161 | +to: "channel:C123", |
| 162 | +}, |
| 163 | +{ channelId: "slack", conversationId: "" }, |
| 164 | +); |
| 165 | + |
| 166 | +expect(result).toBeUndefined(); |
| 167 | +expect(globalThis.fetch).toHaveBeenCalledWith( |
| 168 | +"http://localhost:8750/api/v1/ownership/C123/1234.5678", |
| 169 | +expect.objectContaining({ |
| 170 | +method: "POST", |
| 171 | +body: JSON.stringify({ agent_id: "test-agent" }), |
| 172 | +}), |
| 173 | +); |
| 174 | +}); |
| 175 | + |
149 | 176 | it("cancels when thread owned by another agent", async () => { |
150 | 177 | vi.mocked(globalThis.fetch).mockResolvedValue( |
151 | 178 | new Response(JSON.stringify({ owner: "other-agent" }), { status: 409 }), |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。