feat: Add NTFY notification channel
- Adds NTFY as a new option to the notification channel type dropdown - This includes updating the form schema and related components to support the ntfy_endpoint field for NTFY configurations.
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
+32
-1
@@ -36,7 +36,7 @@ interface NotificationChannelDialogProps {
|
|||||||
|
|
||||||
const baseSchema = z.object({
|
const baseSchema = z.object({
|
||||||
notify_name: z.string().min(1, "Name is required"),
|
notify_name: z.string().min(1, "Name is required"),
|
||||||
notification_type: z.enum(["telegram", "discord", "slack", "signal", "google_chat", "email", "webhook"]),
|
notification_type: z.enum(["telegram", "discord", "slack", "signal", "google_chat", "email", "ntfy", "webhook"]),
|
||||||
enabled: z.boolean().default(true),
|
enabled: z.boolean().default(true),
|
||||||
service_id: z.string().default("global"),
|
service_id: z.string().default("global"),
|
||||||
template_id: z.string().optional(),
|
template_id: z.string().optional(),
|
||||||
@@ -78,6 +78,11 @@ const emailSchema = baseSchema.extend({
|
|||||||
smtp_password: z.string().min(1, "SMTP password is required"),
|
smtp_password: z.string().min(1, "SMTP password is required"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ntfySchema = baseSchema.extend({
|
||||||
|
notification_type: z.literal("ntfy"),
|
||||||
|
ntfy_endpoint: z.string().url("Must be a valid NTFY endpoint URL"),
|
||||||
|
});
|
||||||
|
|
||||||
const webhookSchema = baseSchema.extend({
|
const webhookSchema = baseSchema.extend({
|
||||||
notification_type: z.literal("webhook"),
|
notification_type: z.literal("webhook"),
|
||||||
webhook_url: z.string().url("Must be a valid URL"),
|
webhook_url: z.string().url("Must be a valid URL"),
|
||||||
@@ -91,6 +96,7 @@ const formSchema = z.discriminatedUnion("notification_type", [
|
|||||||
signalSchema,
|
signalSchema,
|
||||||
googleChatSchema,
|
googleChatSchema,
|
||||||
emailSchema,
|
emailSchema,
|
||||||
|
ntfySchema,
|
||||||
webhookSchema
|
webhookSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -133,6 +139,12 @@ const notificationTypeOptions = [
|
|||||||
description: "Send notifications via email",
|
description: "Send notifications via email",
|
||||||
icon: "/upload/notification/email.png"
|
icon: "/upload/notification/email.png"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
value: "ntfy",
|
||||||
|
label: "NTFY",
|
||||||
|
description: "Send notifications via NTFY push service",
|
||||||
|
icon: "/upload/notification/ntfy.png"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: "webhook",
|
value: "webhook",
|
||||||
label: "Webhook",
|
label: "Webhook",
|
||||||
@@ -540,6 +552,25 @@ export const NotificationChannelDialog = ({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{notificationType === "ntfy" && (
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="ntfy_endpoint"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>NTFY Endpoint</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="https://ntfy.sh/your-topic" {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormDescription>
|
||||||
|
The NTFY endpoint URL including your topic (e.g., https://ntfy.sh/checkcle)
|
||||||
|
</FormDescription>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{notificationType === "webhook" && (
|
{notificationType === "webhook" && (
|
||||||
<>
|
<>
|
||||||
<FormField
|
<FormField
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export interface AlertConfiguration {
|
|||||||
collectionId?: string;
|
collectionId?: string;
|
||||||
collectionName?: string;
|
collectionName?: string;
|
||||||
service_id: string;
|
service_id: string;
|
||||||
notification_type: "telegram" | "discord" | "slack" | "signal" | "google_chat" | "email" | "webhook";
|
notification_type: "telegram" | "discord" | "slack" | "signal" | "google_chat" | "email" | "ntfy" | "webhook";
|
||||||
telegram_chat_id?: string;
|
telegram_chat_id?: string;
|
||||||
discord_webhook_url?: string;
|
discord_webhook_url?: string;
|
||||||
signal_number?: string;
|
signal_number?: string;
|
||||||
@@ -28,7 +28,7 @@ export interface AlertConfiguration {
|
|||||||
smtp_password?: string;
|
smtp_password?: string;
|
||||||
webhook_id?: string;
|
webhook_id?: string;
|
||||||
channel_id?: string;
|
channel_id?: string;
|
||||||
// Webhook fields for alert_configurations
|
ntfy_endpoint?: string;
|
||||||
webhook_url?: string;
|
webhook_url?: string;
|
||||||
webhook_payload_template?: string;
|
webhook_payload_template?: string;
|
||||||
}
|
}
|
||||||
@@ -82,9 +82,11 @@ export const alertConfigService = {
|
|||||||
cleanConfig.smtp_server = config.smtp_server || "";
|
cleanConfig.smtp_server = config.smtp_server || "";
|
||||||
cleanConfig.smtp_port = config.smtp_port || "";
|
cleanConfig.smtp_port = config.smtp_port || "";
|
||||||
cleanConfig.smtp_password = config.smtp_password || "";
|
cleanConfig.smtp_password = config.smtp_password || "";
|
||||||
|
|
||||||
} else if (config.notification_type === "webhook") {
|
} else if (config.notification_type === "ntfy") {
|
||||||
|
cleanConfig.ntfy_endpoint = config.ntfy_endpoint || "";
|
||||||
|
|
||||||
|
} else if (config.notification_type === "webhook") {
|
||||||
cleanConfig.webhook_url = config.webhook_url || "";
|
cleanConfig.webhook_url = config.webhook_url || "";
|
||||||
cleanConfig.webhook_payload_template = config.webhook_payload_template || "";
|
cleanConfig.webhook_payload_template = config.webhook_payload_template || "";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user