refactor: dedupe plugin and outbound helpers

This commit is contained in:
Peter Steinberger
2026-04-06 07:40:01 +01:00
parent 9d92de42cf
commit 1d8d2ddaa1
25 changed files with 1825 additions and 1210 deletions

View File

@@ -159,6 +159,39 @@ describe("resolveCommandAuthorization", () => {
expect(otherAuth.isAuthorizedSender).toBe(false);
});
it("uses explicit owner allowlist when allowFrom is empty", () => {
const cfg = {
commands: { ownerAllowFrom: ["whatsapp:+15551234567"] },
channels: { whatsapp: {} },
} as OpenClawConfig;
const ownerAuth = resolveCommandAuthorization({
ctx: {
Provider: "whatsapp",
Surface: "whatsapp",
From: "whatsapp:+15551234567",
SenderE164: "+15551234567",
} as MsgContext,
cfg,
commandAuthorized: true,
});
expect(ownerAuth.senderIsOwner).toBe(true);
expect(ownerAuth.isAuthorizedSender).toBe(true);
const otherAuth = resolveCommandAuthorization({
ctx: {
Provider: "whatsapp",
Surface: "whatsapp",
From: "whatsapp:+19995551234",
SenderE164: "+19995551234",
} as MsgContext,
cfg,
commandAuthorized: true,
});
expect(otherAuth.senderIsOwner).toBe(false);
expect(otherAuth.isAuthorizedSender).toBe(false);
});
it("uses owner allowlist override from context when configured", () => {
setActivePluginRegistry(
createTestRegistry([