refactor: share sender group policy evaluation

This commit is contained in:
Peter Steinberger
2026-03-07 23:12:09 +00:00
parent d228a62143
commit 8c15b8600c
4 changed files with 22 additions and 27 deletions

View File

@@ -57,6 +57,7 @@ export type { AnyAgentTool, OpenClawPluginApi } from "../plugins/types.js";
export { DEFAULT_ACCOUNT_ID, normalizeAgentId } from "../routing/session-key.js";
export type { RuntimeEnv } from "../runtime.js";
export { formatDocsLink } from "../terminal/links.js";
export { evaluateSenderGroupAccessForPolicy } from "./group-access.js";
export type { WizardPrompter } from "../wizard/prompts.js";
export { buildAgentMediaPayload } from "./agent-media-payload.js";
export { readJsonFileWithFallback } from "./json-store.js";

View File

@@ -1,3 +1,4 @@
import { evaluateSenderGroupAccessForPolicy } from "../plugin-sdk/group-access.js";
import { normalizeE164 } from "../utils.js";
export type SignalSender =
@@ -129,15 +130,10 @@ export function isSignalGroupAllowed(params: {
allowFrom: string[];
sender: SignalSender;
}): boolean {
const { groupPolicy, allowFrom, sender } = params;
if (groupPolicy === "disabled") {
return false;
}
if (groupPolicy === "open") {
return true;
}
if (allowFrom.length === 0) {
return false;
}
return isSignalSenderAllowed(sender, allowFrom);
return evaluateSenderGroupAccessForPolicy({
groupPolicy: params.groupPolicy,
groupAllowFrom: params.allowFrom,
senderId: params.sender.raw,
isSenderAllowed: () => isSignalSenderAllowed(params.sender, params.allowFrom),
}).allowed;
}