refactor: share open allowFrom config checks

This commit is contained in:
Peter Steinberger
2026-03-14 02:00:38 +00:00
parent 38b09866b8
commit 55ebdce9c3
4 changed files with 46 additions and 22 deletions

View File

@@ -9,6 +9,7 @@ import {
requireOpenAllowFrom,
} from "openclaw/plugin-sdk/irc";
import { z } from "zod";
import { requireChannelOpenAllowFrom } from "../../shared/config-schema-helpers.js";
const IrcGroupSchema = z
.object({
@@ -69,12 +70,12 @@ export const IrcAccountSchemaBase = z
.strict();
export const IrcAccountSchema = IrcAccountSchemaBase.superRefine((value, ctx) => {
requireOpenAllowFrom({
requireChannelOpenAllowFrom({
channel: "irc",
policy: value.dmPolicy,
allowFrom: value.allowFrom,
ctx,
path: ["allowFrom"],
message: 'channels.irc.dmPolicy="open" requires channels.irc.allowFrom to include "*"',
requireOpenAllowFrom,
});
});
@@ -82,11 +83,11 @@ export const IrcConfigSchema = IrcAccountSchemaBase.extend({
accounts: z.record(z.string(), IrcAccountSchema.optional()).optional(),
defaultAccount: z.string().optional(),
}).superRefine((value, ctx) => {
requireOpenAllowFrom({
requireChannelOpenAllowFrom({
channel: "irc",
policy: value.dmPolicy,
allowFrom: value.allowFrom,
ctx,
path: ["allowFrom"],
message: 'channels.irc.dmPolicy="open" requires channels.irc.allowFrom to include "*"',
requireOpenAllowFrom,
});
});