mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 11:10:20 +00:00
Refactor channel approval capability seams (#58634)
Merged via squash.
Prepared head SHA: c9ad4e4706
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
d9a7ffe003
commit
c87c8e66bf
@@ -7,6 +7,7 @@ import {
|
||||
isTelegramExecApprovalClientEnabled,
|
||||
isTelegramExecApprovalTargetRecipient,
|
||||
resolveTelegramExecApprovalTarget,
|
||||
shouldHandleTelegramExecApprovalRequest,
|
||||
shouldEnableTelegramExecApprovalButtons,
|
||||
shouldInjectTelegramExecApprovalButtons,
|
||||
} from "./exec-approvals.js";
|
||||
@@ -73,6 +74,29 @@ describe("telegram exec approvals", () => {
|
||||
).toBe("dm");
|
||||
});
|
||||
|
||||
it("matches agent filters from the Telegram session key when request.agentId is absent", () => {
|
||||
const cfg = buildConfig({
|
||||
enabled: true,
|
||||
approvers: ["123"],
|
||||
agentFilter: ["ops"],
|
||||
});
|
||||
|
||||
expect(
|
||||
shouldHandleTelegramExecApprovalRequest({
|
||||
cfg,
|
||||
request: {
|
||||
id: "req-1",
|
||||
request: {
|
||||
command: "echo hi",
|
||||
sessionKey: "agent:ops:telegram:direct:123:tail",
|
||||
},
|
||||
createdAtMs: 0,
|
||||
expiresAtMs: 1000,
|
||||
},
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("only injects approval buttons on eligible telegram targets", () => {
|
||||
const dmCfg = buildConfig({ enabled: true, approvers: ["123"], target: "dm" });
|
||||
const channelCfg = buildConfig({ enabled: true, approvers: ["123"], target: "channel" });
|
||||
|
||||
Reference in New Issue
Block a user