mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-31 03:41:51 +00:00
fix(regression): preserve discord thread bindings for plugin commands
This commit is contained in:
@@ -243,6 +243,24 @@ describe("registerPluginCommand", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves Discord thread command bindings with parent channel context intact", () => {
|
||||
expect(
|
||||
__testing.resolveBindingConversationFromCommand({
|
||||
channel: "discord",
|
||||
from: "discord:channel:1480554272859881494",
|
||||
accountId: "default",
|
||||
messageThreadId: "thread-42",
|
||||
threadParentId: "channel-parent-7",
|
||||
}),
|
||||
).toEqual({
|
||||
channel: "discord",
|
||||
accountId: "default",
|
||||
conversationId: "channel:1480554272859881494",
|
||||
parentConversationId: "channel-parent-7",
|
||||
threadId: "thread-42",
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves Telegram topic command bindings without a Telegram registry entry", () => {
|
||||
expect(
|
||||
__testing.resolveBindingConversationFromCommand({
|
||||
|
||||
@@ -148,6 +148,7 @@ function resolveBindingConversationFromCommand(params: {
|
||||
to?: string;
|
||||
accountId?: string;
|
||||
messageThreadId?: string | number;
|
||||
threadParentId?: string;
|
||||
}): {
|
||||
channel: string;
|
||||
accountId: string;
|
||||
@@ -199,6 +200,8 @@ function resolveBindingConversationFromCommand(params: {
|
||||
"conversationId" in target
|
||||
? target.conversationId
|
||||
: `${target.chatType === "direct" ? "user" : "channel"}:${target.to}`,
|
||||
parentConversationId: params.threadParentId?.trim() || undefined,
|
||||
threadId: params.messageThreadId,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
@@ -224,6 +227,7 @@ export async function executePluginCommand(params: {
|
||||
to?: PluginCommandContext["to"];
|
||||
accountId?: PluginCommandContext["accountId"];
|
||||
messageThreadId?: PluginCommandContext["messageThreadId"];
|
||||
threadParentId?: PluginCommandContext["threadParentId"];
|
||||
}): Promise<PluginCommandResult> {
|
||||
const { command, args, senderId, channel, isAuthorizedSender, commandBody, config } = params;
|
||||
|
||||
@@ -244,6 +248,7 @@ export async function executePluginCommand(params: {
|
||||
to: params.to,
|
||||
accountId: params.accountId,
|
||||
messageThreadId: params.messageThreadId,
|
||||
threadParentId: params.threadParentId,
|
||||
});
|
||||
|
||||
const ctx: PluginCommandContext = {
|
||||
@@ -259,6 +264,7 @@ export async function executePluginCommand(params: {
|
||||
to: params.to,
|
||||
accountId: params.accountId,
|
||||
messageThreadId: params.messageThreadId,
|
||||
threadParentId: params.threadParentId,
|
||||
requestConversationBinding: async (bindingParams) => {
|
||||
if (!command.pluginRoot || !bindingConversation) {
|
||||
return {
|
||||
|
||||
@@ -1178,6 +1178,8 @@ export type PluginCommandContext = {
|
||||
accountId?: string;
|
||||
/** Thread/topic id if available */
|
||||
messageThreadId?: string | number;
|
||||
/** Parent conversation id for thread-capable channels */
|
||||
threadParentId?: string;
|
||||
requestConversationBinding: (
|
||||
params?: PluginConversationBindingRequestParams,
|
||||
) => Promise<PluginConversationBindingRequestResult>;
|
||||
|
||||
Reference in New Issue
Block a user