mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 22:24:32 +00:00
refactor: unify channel open-group-policy warning builders
This commit is contained in:
53
src/channels/plugins/group-policy-warnings.ts
Normal file
53
src/channels/plugins/group-policy-warnings.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
export function buildOpenGroupPolicyWarning(params: {
|
||||
surface: string;
|
||||
openBehavior: string;
|
||||
remediation: string;
|
||||
}): string {
|
||||
return `- ${params.surface}: groupPolicy="open" ${params.openBehavior}. ${params.remediation}.`;
|
||||
}
|
||||
|
||||
export function buildOpenGroupPolicyRestrictSendersWarning(params: {
|
||||
surface: string;
|
||||
openScope: string;
|
||||
groupPolicyPath: string;
|
||||
groupAllowFromPath: string;
|
||||
mentionGated?: boolean;
|
||||
}): string {
|
||||
const mentionSuffix = params.mentionGated === false ? "" : " (mention-gated)";
|
||||
return buildOpenGroupPolicyWarning({
|
||||
surface: params.surface,
|
||||
openBehavior: `allows ${params.openScope} to trigger${mentionSuffix}`,
|
||||
remediation: `Set ${params.groupPolicyPath}="allowlist" + ${params.groupAllowFromPath} to restrict senders`,
|
||||
});
|
||||
}
|
||||
|
||||
export function buildOpenGroupPolicyNoRouteAllowlistWarning(params: {
|
||||
surface: string;
|
||||
routeAllowlistPath: string;
|
||||
routeScope: string;
|
||||
groupPolicyPath: string;
|
||||
groupAllowFromPath: string;
|
||||
mentionGated?: boolean;
|
||||
}): string {
|
||||
const mentionSuffix = params.mentionGated === false ? "" : " (mention-gated)";
|
||||
return buildOpenGroupPolicyWarning({
|
||||
surface: params.surface,
|
||||
openBehavior: `with no ${params.routeAllowlistPath} allowlist; any ${params.routeScope} can add + ping${mentionSuffix}`,
|
||||
remediation: `Set ${params.groupPolicyPath}="allowlist" + ${params.groupAllowFromPath} or configure ${params.routeAllowlistPath}`,
|
||||
});
|
||||
}
|
||||
|
||||
export function buildOpenGroupPolicyConfigureRouteAllowlistWarning(params: {
|
||||
surface: string;
|
||||
openScope: string;
|
||||
groupPolicyPath: string;
|
||||
routeAllowlistPath: string;
|
||||
mentionGated?: boolean;
|
||||
}): string {
|
||||
const mentionSuffix = params.mentionGated === false ? "" : " (mention-gated)";
|
||||
return buildOpenGroupPolicyWarning({
|
||||
surface: params.surface,
|
||||
openBehavior: `allows ${params.openScope} to trigger${mentionSuffix}`,
|
||||
remediation: `Set ${params.groupPolicyPath}="allowlist" and configure ${params.routeAllowlistPath}`,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user