@@ -1414,6 +1414,48 @@ describe("handleFeishuMessage command authorization", () => {
|
1414 | 1414 | expect(mockDispatchReplyFromConfig).not.toHaveBeenCalled(); |
1415 | 1415 | }); |
1416 | 1416 | |
| 1417 | +it("admits group when chat_id is explicitly configured under groups, even with empty groupAllowFrom (#67687)", async () => { |
| 1418 | +// Regression for #67687: a group that only sets `groups.<chat_id>.requireMention=false` |
| 1419 | +// (and leaves `groupAllowFrom` empty) should still be admitted under the schema-default |
| 1420 | +// `groupPolicy="allowlist"`. The group's explicit presence in `channels.feishu.groups` |
| 1421 | +// is the operator's allowlist signal, and the per-group `requireMention` override should |
| 1422 | +// then control mention gating for inbound text events. |
| 1423 | +mockShouldComputeCommandAuthorized.mockReturnValue(false); |
| 1424 | + |
| 1425 | +const cfg: ClawdbotConfig = { |
| 1426 | +channels: { |
| 1427 | +feishu: { |
| 1428 | +// groupPolicy intentionally omitted -> schema default is "allowlist" |
| 1429 | +// groupAllowFrom intentionally omitted -> empty [] |
| 1430 | +groups: { |
| 1431 | +"oc-explicit-group": { |
| 1432 | +requireMention: false, |
| 1433 | +}, |
| 1434 | +}, |
| 1435 | +}, |
| 1436 | +}, |
| 1437 | +} as ClawdbotConfig; |
| 1438 | + |
| 1439 | +const event: FeishuMessageEvent = { |
| 1440 | +sender: { |
| 1441 | +sender_id: { open_id: "ou-sender" }, |
| 1442 | +}, |
| 1443 | +message: { |
| 1444 | +message_id: "msg-explicit-group-67687", |
| 1445 | +chat_id: "oc-explicit-group", |
| 1446 | +chat_type: "group", |
| 1447 | +message_type: "text", |
| 1448 | +content: JSON.stringify({ text: "hello bot" }), |
| 1449 | +}, |
| 1450 | +}; |
| 1451 | + |
| 1452 | +await dispatchMessage({ cfg, event }); |
| 1453 | + |
| 1454 | +// Group must be admitted: the inbound finalize/dispatch path runs. |
| 1455 | +expect(mockFinalizeInboundContext).toHaveBeenCalled(); |
| 1456 | +expect(mockDispatchReplyFromConfig).toHaveBeenCalled(); |
| 1457 | +}); |
| 1458 | + |
1417 | 1459 | it("drops message when groupConfig.enabled is false", async () => { |
1418 | 1460 | const cfg: ClawdbotConfig = { |
1419 | 1461 | channels: { |
|