mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 05:52:45 +00:00
refactor(config): share allow/deny channel policy schema
This commit is contained in:
39
src/config/zod-schema.allowdeny.ts
Normal file
39
src/config/zod-schema.allowdeny.ts
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user