mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:10:45 +00:00
fix(hooks): prefer shared outbound conversation context
This commit is contained in:
@@ -88,6 +88,30 @@ describe("thread-ownership plugin", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("prefers shared conversationId over non-canonical Slack target shapes", async () => {
|
||||
vi.mocked(globalThis.fetch).mockResolvedValue(
|
||||
new Response(JSON.stringify({ owner: "test-agent" }), { status: 200 }),
|
||||
);
|
||||
|
||||
const result = await hooks.message_sending(
|
||||
{
|
||||
content: "hello",
|
||||
replyToId: "1234.5678",
|
||||
to: "channel:C123",
|
||||
},
|
||||
{ channelId: "slack", conversationId: "C123" },
|
||||
);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
expect(globalThis.fetch).toHaveBeenCalledWith(
|
||||
"http://localhost:8750/api/v1/ownership/C123/1234.5678",
|
||||
expect.objectContaining({
|
||||
method: "POST",
|
||||
body: JSON.stringify({ agent_id: "test-agent" }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("cancels when thread owned by another agent", async () => {
|
||||
vi.mocked(globalThis.fetch).mockResolvedValue(
|
||||
new Response(JSON.stringify({ owner: "other-agent" }), { status: 409 }),
|
||||
|
||||
@@ -104,7 +104,11 @@ export default definePluginEntry({
|
||||
resolveThreadToken(event.threadId) ||
|
||||
resolveThreadToken(event.metadata?.threadId) ||
|
||||
resolveThreadToken(event.metadata?.threadTs);
|
||||
const channelId = (event.metadata?.channelId as string) ?? event.to;
|
||||
const channelId =
|
||||
normalizeOptionalString(ctx.conversationId) ||
|
||||
normalizeOptionalString(event.metadata?.channelId) ||
|
||||
normalizeOptionalString(event.to) ||
|
||||
"";
|
||||
if (!threadTs) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user