Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const GOTIFY = ({
<BooleanWithDefault
defaultValue={defaults?.params?.useheader}
label="Use Header-based Authentication"
name={`${name}.params.insecureskipverify`}
name={`${name}.params.useheader`}
/>
</FieldSet>
</FieldSet>
Expand Down
62 changes: 34 additions & 28 deletions web/ui/react-app/src/utils/api/types/config-edit/notify/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
headersSchema,
preprocessStringFromHeaderArrayWithDefaults,
} from '@/utils/api/types/config-edit/shared/header/preprocess';
import { nullString } from '@/utils/api/types/config-edit/shared/null-string'; /* Notify 'Options' Schema */
import { nullString } from '@/utils/api/types/config-edit/shared/null-string';
import {
preprocessBooleanFromString,
preprocessStringFromBoolean,
Expand Down Expand Up @@ -399,6 +399,15 @@ export const notifyNtfySchema = notifyBaseSchema.extend({
.default({ host: '', password: '', port: '', topic: '', username: '' }),
});
export type NotifyNtfySchema = z.infer<typeof notifyNtfySchema>;
const notifyNtfySchemaOutgoing = notifyNtfySchema.extend({
params: notifyNtfySchema.shape.params.unwrap().extend({
cache: preprocessStringFromBoolean,
disabletls: preprocessStringFromBoolean,
firebase: preprocessStringFromBoolean,
priority: preprocessStringFromZodEnum(NtfyPriorityZodEnum),
scheme: preprocessStringFromZodEnum(NtfySchemeZodEnum),
}),
});

/* OpsGenie */
export const notifyOpsGenieSchema = notifyBaseSchema.extend({
Expand Down Expand Up @@ -644,6 +653,12 @@ export const notifyGenericSchema = notifyBaseSchema.extend({
}),
});
export type NotifyGenericSchema = z.infer<typeof notifyGenericSchema>;
const notifyGenericSchemaOutgoing = notifyGenericSchema.extend({
params: notifyGenericSchema.shape.params.unwrap().extend({
disabletls: preprocessStringFromBoolean,
requestmethod: preprocessStringFromZodEnum(GenericRequestMethodZodEnum),
}),
});

/* All */
export const notifySchemaMap = {
Expand Down Expand Up @@ -742,46 +757,37 @@ export const notifySchemaMapOutgoingWithDefaults = (
switch (defaults.type) {
// Generic WebHook.
case NOTIFY_TYPE_MAP.GENERIC.value:
return notifyGenericSchema.extend({
params: notifyGenericSchema.shape.params.unwrap().extend({
disabletls: preprocessStringFromBoolean,
requestmethod: preprocessStringFromZodEnum(
GenericRequestMethodZodEnum,
),
}),
url_fields: notifyGenericSchema.shape.url_fields.unwrap().extend({
custom_headers: preprocessStringFromHeaderArrayWithDefaults(
defaults?.url_fields?.custom_headers,
),
json_payload_vars: preprocessStringFromHeaderArrayWithDefaults(
defaults?.url_fields?.json_payload_vars,
),
query_vars: preprocessStringFromHeaderArrayWithDefaults(
defaults?.url_fields?.query_vars,
),
}),
return notifyGenericSchemaOutgoing.extend({
url_fields: notifyGenericSchemaOutgoing.shape.url_fields
.unwrap()
.extend({
custom_headers: preprocessStringFromHeaderArrayWithDefaults(
defaults?.url_fields?.custom_headers,
),
json_payload_vars: preprocessStringFromHeaderArrayWithDefaults(
defaults?.url_fields?.json_payload_vars,
),
query_vars: preprocessStringFromHeaderArrayWithDefaults(
defaults?.url_fields?.query_vars,
),
}),
});
// Gotify
case NOTIFY_TYPE_MAP.GOTIFY.value:
return notifyGotifySchema.extend({
params: notifyGotifySchema.shape.params.unwrap().extend({
return notifyGotifySchemaOutgoing.extend({
params: notifyGotifySchemaOutgoing.shape.params.extend({
extras: preprocessGotifyExtrasToStringWithDefaults(
defaults?.params?.extras,
),
}),
});
// ntfy.
case NOTIFY_TYPE_MAP.NTFY.value:
return notifyNtfySchema.extend({
params: notifyNtfySchema.shape.params.unwrap().extend({
return notifyNtfySchemaOutgoing.extend({
params: notifyNtfySchemaOutgoing.shape.params.extend({
actions: preprocessStringFromNtfyActionsWithDefaults(
defaults?.params?.actions,
),
cache: preprocessStringFromBoolean,
disabletls: preprocessStringFromBoolean,
firebase: preprocessStringFromBoolean,
priority: preprocessStringFromZodEnum(NtfyPriorityZodEnum),
scheme: preprocessStringFromZodEnum(NtfySchemeZodEnum),
}),
});
// OpsGenie.
Expand Down
Loading