mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
fix(filters): validate external filters (#1250)
* fix(filters): Set webhook method default to POST * fix: details.tsx * feat(filters): validate external filters --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
parent
f35d10d7c0
commit
70a2f2d713
1 changed files with 42 additions and 0 deletions
|
@ -223,6 +223,48 @@ const externalFilterSchema = z.object({
|
||||||
webhook_retry_status: z.string().optional(),
|
webhook_retry_status: z.string().optional(),
|
||||||
webhook_retry_attempts: z.number().optional(),
|
webhook_retry_attempts: z.number().optional(),
|
||||||
webhook_retry_delay_seconds: z.number().optional(),
|
webhook_retry_delay_seconds: z.number().optional(),
|
||||||
|
}).superRefine((value, ctx) => {
|
||||||
|
if (!value.name) {
|
||||||
|
ctx.addIssue({
|
||||||
|
message: "Must have a name",
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["name"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.type == "WEBHOOK") {
|
||||||
|
if (!value.webhook_method) {
|
||||||
|
ctx.addIssue({
|
||||||
|
message: "Must select method",
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["webhook_method"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!value.webhook_host) {
|
||||||
|
ctx.addIssue({
|
||||||
|
message: "Must have webhook host",
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["webhook_host"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!value.webhook_expect_status) {
|
||||||
|
ctx.addIssue({
|
||||||
|
message: "Must have webhook expect status",
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["webhook_expect_status"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.type == "EXEC") {
|
||||||
|
if (!value.exec_cmd) {
|
||||||
|
ctx.addIssue({
|
||||||
|
message: "Must have exec cmd",
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["exec_cmd"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const indexerSchema = z.object({
|
const indexerSchema = z.object({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue