From 1e8a16504b7454f0e53692f948548280445b1449 Mon Sep 17 00:00:00 2001 From: Christian Meis Date: Tue, 11 Oct 2022 11:15:33 +0200 Subject: [PATCH] Make icon optional for ntfy notificaation provider. Add Icon header to ntfy request only, if icon is actually defined. --- server/notification-providers/ntfy.js | 11 +++++++---- src/components/notifications/Ntfy.vue | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/notification-providers/ntfy.js b/server/notification-providers/ntfy.js index 3288d8fb..64064f57 100644 --- a/server/notification-providers/ntfy.js +++ b/server/notification-providers/ntfy.js @@ -7,15 +7,18 @@ class Ntfy extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; - try { - await axios.post(`${notification.ntfyserverurl}`, { + var ntfyparams = { "topic": notification.ntfytopic, "message": msg, "priority": notification.ntfyPriority || 4, "title": "Uptime-Kuma", - "icon": notification.ntfyIcon || "", - }); + }; + if (notification.ntfyIcon) { + ntfyparams.icon = notification.ntfyIcon; + } + try { + await axios.post(`${notification.ntfyserverurl}`, ntfyparams); return okMsg; } catch (error) { diff --git a/src/components/notifications/Ntfy.vue b/src/components/notifications/Ntfy.vue index 4728f891..5764429f 100644 --- a/src/components/notifications/Ntfy.vue +++ b/src/components/notifications/Ntfy.vue @@ -19,7 +19,7 @@
- +