diff --git a/src/config/zod-schema.providers-core.ts b/src/config/zod-schema.providers-core.ts index 88bbe934b9a..1f5866eadf0 100644 --- a/src/config/zod-schema.providers-core.ts +++ b/src/config/zod-schema.providers-core.ts @@ -740,7 +740,9 @@ export const IrcAccountSchemaBase = z }) .strict(); -export const IrcAccountSchema = IrcAccountSchemaBase.superRefine((value, ctx) => { +type IrcBaseConfig = z.infer; + +function refineIrcAllowFromAndNickserv(value: IrcBaseConfig, ctx: z.RefinementCtx): void { requireOpenAllowFrom({ policy: value.dmPolicy, allowFrom: value.allowFrom, @@ -755,25 +757,16 @@ export const IrcAccountSchema = IrcAccountSchemaBase.superRefine((value, ctx) => message: "channels.irc.nickserv.register=true requires channels.irc.nickserv.registerEmail", }); } +} + +export const IrcAccountSchema = IrcAccountSchemaBase.superRefine((value, ctx) => { + refineIrcAllowFromAndNickserv(value, ctx); }); export const IrcConfigSchema = IrcAccountSchemaBase.extend({ accounts: z.record(z.string(), IrcAccountSchema.optional()).optional(), }).superRefine((value, ctx) => { - requireOpenAllowFrom({ - policy: value.dmPolicy, - allowFrom: value.allowFrom, - ctx, - path: ["allowFrom"], - message: 'channels.irc.dmPolicy="open" requires channels.irc.allowFrom to include "*"', - }); - if (value.nickserv?.register && !value.nickserv.registerEmail?.trim()) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - path: ["nickserv", "registerEmail"], - message: "channels.irc.nickserv.register=true requires channels.irc.nickserv.registerEmail", - }); - } + refineIrcAllowFromAndNickserv(value, ctx); }); export const IMessageAccountSchemaBase = z