























@@ -1,6 +1,7 @@
11import type * as ConversationRuntime from "openclaw/plugin-sdk/conversation-runtime";
22import { createRuntimeEnv } from "openclaw/plugin-sdk/plugin-test-runtime";
33import type { ResolvedAgentRoute } from "openclaw/plugin-sdk/routing";
4+import { resolveGroupSessionKey } from "openclaw/plugin-sdk/session-store-runtime";
45import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
56import type { ClawdbotConfig, PluginRuntime } from "../runtime-api.js";
67import type { FeishuMessageEvent } from "./bot.js";
@@ -1219,6 +1220,61 @@ describe("handleFeishuMessage command authorization", () => {
12191220expect(mockDispatchReplyFromConfig).toHaveBeenCalledTimes(1);
12201221});
122112221223+it("keeps Feishu group policy bound to the chat while preserving speaker identity", async () => {
1224+mockShouldComputeCommandAuthorized.mockReturnValue(false);
1225+1226+const cfg: ClawdbotConfig = {
1227+channels: {
1228+feishu: {
1229+groupPolicy: "open",
1230+groupSenderAllowFrom: ["ou-allowed"],
1231+groups: {
1232+"oc-group": {
1233+requireMention: false,
1234+},
1235+},
1236+},
1237+},
1238+} as ClawdbotConfig;
1239+1240+const event: FeishuMessageEvent = {
1241+sender: {
1242+sender_id: {
1243+open_id: "ou-allowed",
1244+},
1245+},
1246+message: {
1247+message_id: "msg-group-context-79457",
1248+chat_id: "oc-group",
1249+chat_type: "group",
1250+message_type: "text",
1251+content: JSON.stringify({ text: "hello" }),
1252+},
1253+};
1254+1255+await dispatchMessage({ cfg, event });
1256+1257+const finalized = mockFinalizeInboundContext.mock.calls.at(-1)?.[0];
1258+expect(finalized).toEqual(
1259+expect.objectContaining({
1260+ChatType: "group",
1261+From: "feishu:ou-allowed",
1262+To: "chat:oc-group",
1263+OriginatingChannel: "feishu",
1264+OriginatingTo: "chat:oc-group",
1265+SenderId: "ou-allowed",
1266+}),
1267+);
1268+expect(resolveGroupSessionKey(finalized as never)).toEqual(
1269+expect.objectContaining({
1270+channel: "feishu",
1271+id: "oc-group",
1272+key: "feishu:group:oc-group",
1273+}),
1274+);
1275+expect(mockDispatchReplyFromConfig).toHaveBeenCalledTimes(1);
1276+});
1277+12221278it("blocks group sender when global groupSenderAllowFrom excludes sender", async () => {
12231279mockShouldComputeCommandAuthorized.mockReturnValue(false);
12241280此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。