aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-12-13 17:48:49 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-12-17 13:21:59 +0100
commit6bee4675509e874d2f2ed8ee960f251b5667a451 (patch)
tree1db8abeb926112c6ce7d98b9999e29792a4cd2ba /mod
parentd1b9b1b410933e0510845c245f742a7df172dc61 (diff)
mod/notification-ntfy: add basic authentication in headersHEADstagingnextmain
This makes it a bit easier and straight forward as we pass the headers anyway.
Diffstat (limited to 'mod')
-rw-r--r--mod/notification-ntfy.rsc9
1 files changed, 6 insertions, 3 deletions
diff --git a/mod/notification-ntfy.rsc b/mod/notification-ntfy.rsc
index 7e4eaf0..f8351fd 100644
--- a/mod/notification-ntfy.rsc
+++ b/mod/notification-ntfy.rsc
@@ -39,7 +39,7 @@
:do {
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
http-header-field=($Message->"headers") http-data=($Message->"text") \
- ($Message->"url") user=($Message->"user") password=($Message->"pass") as-value;
+ ($Message->"url") as-value;
:set ($NtfyQueue->$Id);
} on-error={
$LogPrint debug $0 ("Sending queued Ntfy message failed.");
@@ -96,6 +96,9 @@
:local Headers ({ [ $FetchUserAgentStr ($Notification->"origin") ]; \
("Priority: " . [ $IfThenElse ($Notification->"silent") "low" "default" ]); \
("Title: " . "[" . $IdentityExtra . $Identity . "] " . ($Notification->"subject")) });
+ :if ([ :len $User ] > 0 || [ :len $Pass ] > 0) do={
+ :set Headers ($Headers, ("Authorization: Basic " . [ :convert to=base64 ($User . ":" . $Pass) ]));
+ }
:if ([ :len $Token ] > 0) do={
:set Headers ($Headers, ("Authorization: Bearer " . $Token));
}
@@ -112,7 +115,7 @@
}
}
/tool/fetch check-certificate=yes-without-crl output=none http-method=post \
- http-header-field=$Headers http-data=$Text $Url user=$User password=$Pass as-value;
+ http-header-field=$Headers http-data=$Text $Url as-value;
} on-error={
$LogPrint info $0 ("Failed sending ntfy notification! Queuing...");
@@ -123,7 +126,7 @@
"This message was queued since " . [ /system/clock/get date ] . " " . \
[ /system/clock/get time ] . " and may be obsolete.");
:set ($NtfyQueue->[ :len $NtfyQueue ]) \
- { url=$Url; user=$User; pass=$Pass; headers=$Headers; text=$Text };
+ { url=$Url; headers=$Headers; text=$Text };
:if ([ :len [ /system/scheduler/find where name="_FlushNtfyQueue" ] ] = 0) do={
/system/scheduler/add name="_FlushNtfyQueue" interval=1m start-time=startup \
on-event=(":global FlushNtfyQueue; \$FlushNtfyQueue;");