mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-05 22:32:12 +00:00
fix: honor feishu action discovery account config
This commit is contained in:
@@ -62,8 +62,8 @@ vi.mock("../../../src/channels/plugins/bundled.js", () => ({
|
||||
|
||||
let feishuPlugin: typeof import("./channel.js").feishuPlugin;
|
||||
|
||||
function getDescribedActions(cfg: OpenClawConfig): string[] {
|
||||
return [...(feishuPlugin.actions?.describeMessageTool?.({ cfg })?.actions ?? [])];
|
||||
function getDescribedActions(cfg: OpenClawConfig, accountId?: string): string[] {
|
||||
return [...(feishuPlugin.actions?.describeMessageTool?.({ cfg, accountId })?.actions ?? [])];
|
||||
}
|
||||
|
||||
function createLegacyFeishuButtonCard(value: { command?: string; text?: string }) {
|
||||
@@ -279,6 +279,58 @@ describe("feishuPlugin actions", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("honors the selected Feishu account during discovery", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
feishu: {
|
||||
enabled: true,
|
||||
actions: { reactions: false },
|
||||
accounts: {
|
||||
default: {
|
||||
enabled: true,
|
||||
appId: "cli_main",
|
||||
appSecret: "secret_main",
|
||||
actions: { reactions: false },
|
||||
},
|
||||
work: {
|
||||
enabled: true,
|
||||
appId: "cli_work",
|
||||
appSecret: "secret_work",
|
||||
actions: { reactions: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(getDescribedActions(cfg, "default")).toEqual([
|
||||
"send",
|
||||
"read",
|
||||
"edit",
|
||||
"thread-reply",
|
||||
"pin",
|
||||
"list-pins",
|
||||
"unpin",
|
||||
"member-info",
|
||||
"channel-info",
|
||||
"channel-list",
|
||||
]);
|
||||
expect(getDescribedActions(cfg, "work")).toEqual([
|
||||
"send",
|
||||
"read",
|
||||
"edit",
|
||||
"thread-reply",
|
||||
"pin",
|
||||
"list-pins",
|
||||
"unpin",
|
||||
"member-info",
|
||||
"channel-info",
|
||||
"channel-list",
|
||||
"react",
|
||||
"reactions",
|
||||
]);
|
||||
});
|
||||
|
||||
it("sends text messages", async () => {
|
||||
sendMessageFeishuMock.mockResolvedValueOnce({ messageId: "om_sent", chatId: "oc_group_1" });
|
||||
|
||||
|
||||
@@ -141,13 +141,19 @@ const collectFeishuSecurityWarnings = createAllowlistProviderGroupPolicyWarningC
|
||||
|
||||
function describeFeishuMessageTool({
|
||||
cfg,
|
||||
accountId,
|
||||
}: Parameters<
|
||||
NonNullable<ChannelMessageActionAdapter["describeMessageTool"]>
|
||||
>[0]): ChannelMessageToolDiscovery {
|
||||
const enabledAccounts = accountId
|
||||
? [resolveFeishuAccount({ cfg, accountId })].filter((account) => account.enabled && account.configured)
|
||||
: listEnabledFeishuAccounts(cfg);
|
||||
const enabled =
|
||||
cfg.channels?.feishu?.enabled !== false &&
|
||||
Boolean(inspectFeishuCredentials(cfg.channels?.feishu as FeishuConfig | undefined));
|
||||
if (listEnabledFeishuAccounts(cfg).length === 0) {
|
||||
enabledAccounts.length > 0 ||
|
||||
(!accountId &&
|
||||
cfg.channels?.feishu?.enabled !== false &&
|
||||
Boolean(inspectFeishuCredentials(cfg.channels?.feishu as FeishuConfig | undefined)));
|
||||
if (enabledAccounts.length === 0) {
|
||||
return {
|
||||
actions: [],
|
||||
capabilities: enabled ? ["cards"] : [],
|
||||
@@ -172,7 +178,11 @@ function describeFeishuMessageTool({
|
||||
"channel-info",
|
||||
"channel-list",
|
||||
]);
|
||||
if (areAnyFeishuReactionActionsEnabled(cfg)) {
|
||||
if (
|
||||
(accountId
|
||||
? enabledAccounts.some((account) => isFeishuReactionsActionEnabled({ cfg, account }))
|
||||
: areAnyFeishuReactionActionsEnabled(cfg))
|
||||
) {
|
||||
actions.add("react");
|
||||
actions.add("reactions");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user