mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-07 22:44:16 +00:00
fix(feishu): restore group command fallback and plugin deps
This commit is contained in:
@@ -264,4 +264,52 @@ describe("handleFeishuMessage command authorization", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to top-level allowFrom for group command authorization", async () => {
|
||||
mockShouldComputeCommandAuthorized.mockReturnValue(true);
|
||||
mockResolveCommandAuthorizedFromAuthorizers.mockReturnValue(true);
|
||||
|
||||
const cfg: ClawdbotConfig = {
|
||||
commands: { useAccessGroups: true },
|
||||
channels: {
|
||||
feishu: {
|
||||
allowFrom: ["ou-admin"],
|
||||
groups: {
|
||||
"oc-group": {
|
||||
requireMention: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
|
||||
const event: FeishuMessageEvent = {
|
||||
sender: {
|
||||
sender_id: {
|
||||
open_id: "ou-admin",
|
||||
},
|
||||
},
|
||||
message: {
|
||||
message_id: "msg-group-command-fallback",
|
||||
chat_id: "oc-group",
|
||||
chat_type: "group",
|
||||
message_type: "text",
|
||||
content: JSON.stringify({ text: "/status" }),
|
||||
},
|
||||
};
|
||||
|
||||
await dispatchMessage({ cfg, event });
|
||||
|
||||
expect(mockResolveCommandAuthorizedFromAuthorizers).toHaveBeenCalledWith({
|
||||
useAccessGroups: true,
|
||||
authorizers: [{ configured: true, allowed: true }],
|
||||
});
|
||||
expect(mockFinalizeInboundContext).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
ChatType: "group",
|
||||
CommandAuthorized: true,
|
||||
SenderId: "ou-admin",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -693,7 +693,9 @@ export async function handleFeishuMessage(params: {
|
||||
return;
|
||||
}
|
||||
|
||||
const commandAllowFrom = isGroup ? (groupConfig?.allowFrom ?? []) : effectiveDmAllowFrom;
|
||||
const commandAllowFrom = isGroup
|
||||
? (groupConfig?.allowFrom ?? configAllowFrom)
|
||||
: effectiveDmAllowFrom;
|
||||
const senderAllowedForCommands = resolveFeishuAllowlistMatch({
|
||||
allowFrom: commandAllowFrom,
|
||||
senderId: ctx.senderOpenId,
|
||||
|
||||
Reference in New Issue
Block a user