mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
fix: normalize bound delivery binding matches
This commit is contained in:
@@ -122,6 +122,34 @@ describe("bound delivery router", () => {
|
||||
},
|
||||
expectedConversationId: "thread-2",
|
||||
},
|
||||
{
|
||||
name: "normalizes adapter binding conversations before requester matching",
|
||||
bindings: [
|
||||
{
|
||||
...createDiscordBinding(TARGET_SESSION_KEY, "thread-1", 1),
|
||||
conversation: {
|
||||
channel: " discord ",
|
||||
accountId: " runtime ",
|
||||
conversationId: " thread-1 ",
|
||||
},
|
||||
},
|
||||
{
|
||||
...createDiscordBinding(TARGET_SESSION_KEY, "thread-2", 2),
|
||||
conversation: {
|
||||
channel: " DISCORD ",
|
||||
accountId: " Runtime ",
|
||||
conversationId: " thread-2 ",
|
||||
},
|
||||
},
|
||||
],
|
||||
requesterConversationId: "thread-2",
|
||||
failClosed: true,
|
||||
expected: {
|
||||
mode: "bound",
|
||||
reason: "requester-match",
|
||||
},
|
||||
expectedConversationId: " thread-2 ",
|
||||
},
|
||||
{
|
||||
name: "falls back for invalid requester conversation values",
|
||||
bindings: [createDiscordBinding(TARGET_SESSION_KEY, "thread-1", 1)],
|
||||
|
||||
@@ -32,16 +32,20 @@ function resolveBindingForRequester(
|
||||
bindings: SessionBindingRecord[],
|
||||
): SessionBindingRecord | null {
|
||||
const matchingChannelAccount = bindings.filter(
|
||||
(entry) =>
|
||||
entry.conversation.channel === requester.channel &&
|
||||
entry.conversation.accountId === requester.accountId,
|
||||
(entry) => {
|
||||
const conversation = normalizeConversationRef(entry.conversation);
|
||||
return (
|
||||
conversation.channel === requester.channel && conversation.accountId === requester.accountId
|
||||
);
|
||||
},
|
||||
);
|
||||
if (matchingChannelAccount.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const exactConversation = matchingChannelAccount.find(
|
||||
(entry) => entry.conversation.conversationId === requester.conversationId,
|
||||
(entry) =>
|
||||
normalizeConversationRef(entry.conversation).conversationId === requester.conversationId,
|
||||
);
|
||||
if (exactConversation) {
|
||||
return exactConversation;
|
||||
|
||||
Reference in New Issue
Block a user