refactor(config): share allow/deny channel policy schema

This commit is contained in:
Peter Steinberger
2026-02-14 14:28:03 +00:00
parent 268c14f021
commit 747b11c83e
3 changed files with 43 additions and 61 deletions

View File

@@ -0,0 +1,39 @@
import { z } from "zod";
const AllowDenyActionSchema = z.union([z.literal("allow"), z.literal("deny")]);
const AllowDenyChatTypeSchema = z
.union([
z.literal("direct"),
z.literal("group"),
z.literal("channel"),
/** @deprecated Use `direct` instead. Kept for backward compatibility. */
z.literal("dm"),
])
.optional();
export function createAllowDenyChannelRulesSchema() {
return z
.object({
default: AllowDenyActionSchema.optional(),
rules: z
.array(
z
.object({
action: AllowDenyActionSchema,
match: z
.object({
channel: z.string().optional(),
chatType: AllowDenyChatTypeSchema,
keyPrefix: z.string().optional(),
})
.strict()
.optional(),
})
.strict(),
)
.optional(),
})
.strict()
.optional();
}