diff --git a/server/notification-providers/ntfy.js b/server/notification-providers/ntfy.js index d88199b3a..ebe5a1709 100644 --- a/server/notification-providers/ntfy.js +++ b/server/notification-providers/ntfy.js @@ -33,10 +33,27 @@ class Ntfy extends NotificationProvider { config = this.getAxiosConfigWithProxy(config); // If heartbeatJSON is null, assume non monitoring notification (Certificate warning) or testing. if (heartbeatJSON == null) { + // Default values for test notification + let title = (monitorJSON?.name || notification.ntfytopic) + " [Uptime-Kuma]"; + let message = msg; + + // Apply custom templates from notification settings if enabled + if (notification.ntfyUseTemplate) { + const customTitle = notification.ntfyCustomTitle?.trim() || ""; + if (customTitle !== "") { + title = await this.renderTemplate(customTitle, msg, monitorJSON, heartbeatJSON); + } + + const customMessage = notification.ntfyCustomMessage?.trim() || ""; + if (customMessage !== "") { + message = await this.renderTemplate(customMessage, msg, monitorJSON, heartbeatJSON); + } + } + let ntfyTestData = { topic: notification.ntfytopic, - title: (monitorJSON?.name || notification.ntfytopic) + " [Uptime-Kuma]", - message: msg, + title: title, + message: message, priority: notification.ntfyPriority, tags: ["test_tube"], }; @@ -70,11 +87,28 @@ class Ntfy extends NotificationProvider { tags = tags.concat(monitorTagNames); } + // Default values + let title = monitorJSON.name + " " + status + " [Uptime-Kuma]"; + let message = heartbeatJSON.msg; + + // Apply custom templates from notification settings if enabled + if (notification.ntfyUseTemplate) { + const customTitle = notification.ntfyCustomTitle?.trim() || ""; + const customMessage = notification.ntfyCustomMessage?.trim() || ""; + + if (customTitle !== "") { + title = await this.renderTemplate(customTitle, msg, monitorJSON, heartbeatJSON); + } + if (customMessage !== "") { + message = await this.renderTemplate(customMessage, msg, monitorJSON, heartbeatJSON); + } + } + let data = { topic: notification.ntfytopic, - message: heartbeatJSON.msg, + message: message, priority: priority, - title: monitorJSON.name + " " + status + " [Uptime-Kuma]", + title: title, tags: tags, }; diff --git a/src/components/notifications/Ntfy.vue b/src/components/notifications/Ntfy.vue index fb5491b91..fb094f6ac 100644 --- a/src/components/notifications/Ntfy.vue +++ b/src/components/notifications/Ntfy.vue @@ -102,14 +102,59 @@ {{ $t("ntfyCallHelptext") }} + +