From 17722c31e31eec035d8896566e9eb5596951d022 Mon Sep 17 00:00:00 2001 From: Miguel Ribeiro Date: Fri, 21 Jun 2024 15:15:11 +0200 Subject: [PATCH] fix: ntfy notifications (#394) --- endpoints/cronjobs/sendnotifications.php | 5 ++++- endpoints/notifications/testntfynotifications.php | 5 ++--- includes/version.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/endpoints/cronjobs/sendnotifications.php b/endpoints/cronjobs/sendnotifications.php index ad6d09d19..192e3cf0f 100644 --- a/endpoints/cronjobs/sendnotifications.php +++ b/endpoints/cronjobs/sendnotifications.php @@ -472,7 +472,10 @@ $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $ntfy['host'] . '/' . $ntfy['topic']); + $ntfyHost = rtrim($ntfy["host"], '/'); + $ntfyTopic = $ntfy['topic']; + + curl_setopt($ch, CURLOPT_URL, $ntfyHost . '/' . $ntfyTopic); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $message); curl_setopt($ch, CURLOPT_HTTPHEADER, $customheaders); diff --git a/endpoints/notifications/testntfynotifications.php b/endpoints/notifications/testntfynotifications.php index 612d06186..da0d29f81 100644 --- a/endpoints/notifications/testntfynotifications.php +++ b/endpoints/notifications/testntfynotifications.php @@ -23,7 +23,7 @@ ]; echo json_encode($response); } else { - $host = $data["host"]; + $host = rtrim($data["host"], '/'); $topic = $data["topic"]; $headers = json_decode($data["headers"], true); $customheaders = array_map(function($key, $value) { @@ -42,6 +42,7 @@ curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $message); curl_setopt($ch, CURLOPT_HTTPHEADER, $customheaders); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute the request $response = curl_exec($ch); @@ -55,8 +56,6 @@ "success" => false, "message" => translate('notification_failed', $i18n) ])); - } else { - print_r($response); } die(json_encode([ diff --git a/includes/version.php b/includes/version.php index a1b4c4777..7eb8e1e44 100644 --- a/includes/version.php +++ b/includes/version.php @@ -1,3 +1,3 @@