From 06ba38aa1532b0759b426f1e17142f0c8ff57f43 Mon Sep 17 00:00:00 2001 From: Tola Leng Date: Tue, 9 Sep 2025 17:48:25 +0700 Subject: [PATCH] feat: Add NTFY API token field for Token-based authentication to ntfy server - Add the api_token field for NTFY notifications in both the dialog and service to save it to PB. NTFY schema to include api_token field. --- .../NotificationChannelDialog.tsx | 51 +++++++++++++------ .../src/services/alertConfigService.ts | 1 + 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/application/src/components/settings/notification-settings/NotificationChannelDialog.tsx b/application/src/components/settings/notification-settings/NotificationChannelDialog.tsx index ef0591d..b927389 100644 --- a/application/src/components/settings/notification-settings/NotificationChannelDialog.tsx +++ b/application/src/components/settings/notification-settings/NotificationChannelDialog.tsx @@ -83,6 +83,7 @@ const emailSchema = baseSchema.extend({ const ntfySchema = baseSchema.extend({ notification_type: z.literal("ntfy"), ntfy_endpoint: z.string().url("Must be a valid NTFY endpoint URL"), + api_token: z.string().optional(), }); const pushoverSchema = baseSchema.extend({ @@ -595,22 +596,40 @@ export const NotificationChannelDialog = ({ )} {notificationType === "ntfy" && ( - ( - - NTFY Endpoint - - - - - The NTFY endpoint URL including your topic (e.g., https://ntfy.sh/checkcle) - - - - )} - /> + <> + ( + + NTFY Endpoint + + + + + The NTFY endpoint URL including your topic (e.g., https://ntfy.sh/checkcle) + + + + )} + /> + ( + + API Token (Optional) + + + + + Optional API token for authentication with NTFY server + + + + )} + /> + )} {notificationType === "pushover" && ( diff --git a/application/src/services/alertConfigService.ts b/application/src/services/alertConfigService.ts index c76a494..d6f0c30 100644 --- a/application/src/services/alertConfigService.ts +++ b/application/src/services/alertConfigService.ts @@ -88,6 +88,7 @@ export const alertConfigService = { } else if (config.notification_type === "ntfy") { cleanConfig.ntfy_endpoint = config.ntfy_endpoint || ""; + cleanConfig.api_token = config.api_token || ""; } else if (config.notification_type === "pushover") { cleanConfig.api_token = config.api_token || "";