mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 04:01:05 +00:00
fix: preserve sender-keyed plugin command bindings
This commit is contained in:
@@ -186,6 +186,22 @@ beforeEach(() => {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
pluginId: "signal",
|
||||
source: "test",
|
||||
plugin: {
|
||||
...createChannelTestPluginBase({ id: "signal", label: "Signal" }),
|
||||
commands: {
|
||||
nativeCommandsAutoEnabled: true,
|
||||
},
|
||||
bindings: {
|
||||
resolveCommandConversation: ({ senderId }: { senderId?: string }) => {
|
||||
const normalizedSenderId = senderId?.trim();
|
||||
return normalizedSenderId ? { conversationId: `dm:${normalizedSenderId}` } : null;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
]),
|
||||
);
|
||||
});
|
||||
@@ -446,6 +462,19 @@ describe("registerPluginCommand", () => {
|
||||
},
|
||||
expected: null,
|
||||
},
|
||||
{
|
||||
name: "resolves sender-keyed command bindings when only senderId is available",
|
||||
params: {
|
||||
channel: "signal",
|
||||
senderId: "signal-user-42",
|
||||
accountId: "default",
|
||||
},
|
||||
expected: {
|
||||
channel: "signal",
|
||||
accountId: "default",
|
||||
conversationId: "dm:signal-user-42",
|
||||
},
|
||||
},
|
||||
] as const)("$name", ({ params, expected }) => {
|
||||
expectBindingConversationCase(params, expected);
|
||||
});
|
||||
|
||||
@@ -116,6 +116,7 @@ function sanitizeArgs(args: string | undefined): string | undefined {
|
||||
function resolveBindingConversationFromCommand(params: {
|
||||
config?: OpenClawConfig;
|
||||
channel: string;
|
||||
senderId?: string;
|
||||
from?: string;
|
||||
to?: string;
|
||||
accountId?: string;
|
||||
@@ -140,6 +141,7 @@ function resolveBindingConversationFromCommand(params: {
|
||||
accountId: params.accountId,
|
||||
threadId: params.messageThreadId,
|
||||
threadParentId: params.threadParentId,
|
||||
senderId: params.senderId,
|
||||
originatingTo: params.from,
|
||||
commandTo: params.to,
|
||||
fallbackTo: params.to ?? params.from,
|
||||
@@ -187,6 +189,7 @@ export async function executePluginCommand(params: {
|
||||
const bindingConversation = resolveBindingConversationFromCommand({
|
||||
config,
|
||||
channel,
|
||||
senderId,
|
||||
from: params.from,
|
||||
to: params.to,
|
||||
accountId: params.accountId,
|
||||
|
||||
Reference in New Issue
Block a user