mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:50:43 +00:00
fix(hooks): canonicalize thread ownership conversation ids
This commit is contained in:
@@ -161,6 +161,29 @@ describe("thread-ownership plugin", () => {
|
||||
expect(globalThis.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("tracks mentions under the shared conversationId when inbound metadata is non-canonical", async () => {
|
||||
await hooks.message_received(
|
||||
{
|
||||
content: "Hey @TestBot help me",
|
||||
threadId: "9999.0002",
|
||||
metadata: { channelId: "channel:C456" },
|
||||
},
|
||||
{ channelId: "slack", conversationId: "C456" },
|
||||
);
|
||||
|
||||
const result = await hooks.message_sending(
|
||||
{
|
||||
content: "Sure!",
|
||||
replyToId: "9999.0002",
|
||||
to: "channel:C456",
|
||||
},
|
||||
{ channelId: "slack", conversationId: "C456" },
|
||||
);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
expect(globalThis.fetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("ignores @-mentions on non-slack channels", async () => {
|
||||
// Use a unique thread key so module-level state from other tests doesn't interfere.
|
||||
await hooks.message_received(
|
||||
|
||||
@@ -80,7 +80,10 @@ export default definePluginEntry({
|
||||
resolveThreadToken(event.threadId) ||
|
||||
resolveThreadToken(event.metadata?.threadId) ||
|
||||
resolveThreadToken(event.metadata?.threadTs);
|
||||
const channelId = (event.metadata?.channelId as string) ?? ctx.conversationId ?? "";
|
||||
const channelId =
|
||||
normalizeOptionalString(ctx.conversationId) ||
|
||||
normalizeOptionalString(event.metadata?.channelId) ||
|
||||
"";
|
||||
if (!threadTs || !channelId) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user