Feishu: normalize group slash command probing

- Feishu/group slash command detection: normalize group mention wrappers before command-authorization probing so mention-prefixed commands are recognized in group routing.\n- Source PR: #36011\n- Contributor: @liuxiaopai-ai\n\nCo-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>\nCo-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com>
This commit is contained in:
Liu Xiaopai
2026-03-06 01:56:59 +08:00
committed by GitHub
parent 995ae73d5f
commit 174eeea76c
3 changed files with 50 additions and 1 deletions

View File

@@ -521,6 +521,42 @@ describe("handleFeishuMessage command authorization", () => {
);
});
it("normalizes group mention-prefixed slash commands before command-auth probing", async () => {
mockShouldComputeCommandAuthorized.mockReturnValue(true);
const cfg: ClawdbotConfig = {
channels: {
feishu: {
groups: {
"oc-group": {
requireMention: false,
},
},
},
},
} as ClawdbotConfig;
const event: FeishuMessageEvent = {
sender: {
sender_id: {
open_id: "ou-attacker",
},
},
message: {
message_id: "msg-group-mention-command-probe",
chat_id: "oc-group",
chat_type: "group",
message_type: "text",
content: JSON.stringify({ text: "@_user_1/model" }),
mentions: [{ key: "@_user_1", id: { open_id: "ou-bot" }, name: "Bot", tenant_key: "" }],
},
};
await dispatchMessage({ cfg, event });
expect(mockShouldComputeCommandAuthorized).toHaveBeenCalledWith("/model", cfg);
});
it("falls back to top-level allowFrom for group command authorization", async () => {
mockShouldComputeCommandAuthorized.mockReturnValue(true);
mockResolveCommandAuthorizedFromAuthorizers.mockReturnValue(true);