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:
+32
-1
@@ -36,7 +36,7 @@ interface NotificationChannelDialogProps {
|
||||
|
||||
const baseSchema = z.object({
|
||||
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),
|
||||
service_id: z.string().default("global"),
|
||||
template_id: z.string().optional(),
|
||||
@@ -78,6 +78,11 @@ const emailSchema = baseSchema.extend({
|
||||
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({
|
||||
notification_type: z.literal("webhook"),
|
||||
webhook_url: z.string().url("Must be a valid URL"),
|
||||
@@ -91,6 +96,7 @@ const formSchema = z.discriminatedUnion("notification_type", [
|
||||
signalSchema,
|
||||
googleChatSchema,
|
||||
emailSchema,
|
||||
ntfySchema,
|
||||
webhookSchema
|
||||
]);
|
||||
|
||||
@@ -133,6 +139,12 @@ const notificationTypeOptions = [
|
||||
description: "Send notifications via email",
|
||||
icon: "/upload/notification/email.png"
|
||||
},
|
||||
{
|
||||
value: "ntfy",
|
||||
label: "NTFY",
|
||||
description: "Send notifications via NTFY push service",
|
||||
icon: "/upload/notification/ntfy.png"
|
||||
},
|
||||
{
|
||||
value: "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" && (
|
||||
<>
|
||||
<FormField
|
||||
|
||||
@@ -7,7 +7,7 @@ export interface AlertConfiguration {
|
||||
collectionId?: string;
|
||||
collectionName?: 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;
|
||||
discord_webhook_url?: string;
|
||||
signal_number?: string;
|
||||
@@ -28,7 +28,7 @@ export interface AlertConfiguration {
|
||||
smtp_password?: string;
|
||||
webhook_id?: string;
|
||||
channel_id?: string;
|
||||
// Webhook fields for alert_configurations
|
||||
ntfy_endpoint?: string;
|
||||
webhook_url?: string;
|
||||
webhook_payload_template?: string;
|
||||
}
|
||||
@@ -82,9 +82,11 @@ export const alertConfigService = {
|
||||
cleanConfig.smtp_server = config.smtp_server || "";
|
||||
cleanConfig.smtp_port = config.smtp_port || "";
|
||||
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_payload_template = config.webhook_payload_template || "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user