diff --git a/server/notification-providers/ntfy.js b/server/notification-providers/ntfy.js index b21e9800..2d8378e5 100644 --- a/server/notification-providers/ntfy.js +++ b/server/notification-providers/ntfy.js @@ -10,10 +10,14 @@ class Ntfy extends NotificationProvider { let okMsg = "Sent Successfully."; try { let headers = {}; - if (notification.ntfyusername) { + if (notification.ntfyAuthenticationMethod === "usernamePassword") { headers = { "Authorization": "Basic " + Buffer.from(notification.ntfyusername + ":" + notification.ntfypassword).toString("base64"), }; + } else if (notification.ntfyAuthenticationMethod === "accessToken") { + headers = { + "Authorization": "Bearer " + notification.ntfyaccesstoken, + }; } // If heartbeatJSON is null, assume non monitoring notification (Certificate warning) or testing. if (heartbeatJSON == null) { diff --git a/src/components/notifications/Ntfy.vue b/src/components/notifications/Ntfy.vue index df21c5c5..57fac671 100644 --- a/src/components/notifications/Ntfy.vue +++ b/src/components/notifications/Ntfy.vue @@ -16,17 +16,29 @@
- + + +
+
+
-
- +
+
+
+ +
+ +
+
@@ -40,11 +52,29 @@ export default { components: { HiddenInput, }, + computed: { + authenticationMethods() { + return { + none: this.$t("None"), + usernamePassword: this.$t("ntfyUsernameAndPassword"), + accessToken: this.$t("Access Token") + }; + } + }, mounted() { if (typeof this.$parent.notification.ntfyPriority === "undefined") { this.$parent.notification.ntfyserverurl = "https://ntfy.sh"; this.$parent.notification.ntfyPriority = 5; } + + // Handling notifications that added before 1.22.0 + if (typeof this.$parent.notification.ntfyAuthenticationMethod === "undefined") { + if (!this.$parent.notification.ntfyusername) { + this.$parent.notification.ntfyAuthenticationMethod = "none"; + } else { + this.$parent.notification.ntfyAuthenticationMethod = "usernamePassword"; + } + } }, }; diff --git a/src/lang/de-CH.json b/src/lang/de-CH.json index df66d1bc..3f3a860c 100644 --- a/src/lang/de-CH.json +++ b/src/lang/de-CH.json @@ -736,6 +736,8 @@ "lunaseaTarget": "Ziel", "lunaseaDeviceID": "Geräte-ID", "lunaseaUserID": "Benutzer-ID", + "ntfyAuthenticationMethod": "Authentifizierungsmethode", + "ntfyUsernameAndPassword": "Benutzername und Passwort", "twilioAccountSID": "Account SID", "twilioFromNumber": "Absender", "twilioToNumber": "Empfänger", diff --git a/src/lang/de-DE.json b/src/lang/de-DE.json index 0e1c0ce1..48a8cd71 100644 --- a/src/lang/de-DE.json +++ b/src/lang/de-DE.json @@ -739,6 +739,8 @@ "lunaseaDeviceID": "Geräte-ID", "lunaseaTarget": "Ziel", "lunaseaUserID": "Benutzer-ID", + "ntfyAuthenticationMethod": "Authentifizierungsmethode", + "ntfyUsernameAndPassword": "Benutzername und Passwort", "twilioAccountSID": "Account SID", "twilioFromNumber": "Absender", "twilioToNumber": "Empfänger", diff --git a/src/lang/en.json b/src/lang/en.json index 4a2fe881..f33a7de3 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -714,6 +714,8 @@ "lunaseaTarget": "Target", "lunaseaDeviceID": "Device ID", "lunaseaUserID": "User ID", + "ntfyAuthenticationMethod": "Authentication Method", + "ntfyUsernameAndPassword": "Username and Password", "twilioAccountSID": "Account SID", "twilioAuthToken": "Auth Token", "twilioFromNumber": "From Number",