diff options
-rw-r--r-- | doc/mod/notification-ntfy.md | 5 | ||||
-rw-r--r-- | global-config.rsc | 2 | ||||
-rw-r--r-- | global-functions.rsc | 2 | ||||
-rw-r--r-- | mod/notification-ntfy.rsc | 14 | ||||
-rw-r--r-- | news-and-changes.rsc | 1 |
5 files changed, 20 insertions, 4 deletions
diff --git a/doc/mod/notification-ntfy.md b/doc/mod/notification-ntfy.md index afa3109..b2330a5 100644 --- a/doc/mod/notification-ntfy.md +++ b/doc/mod/notification-ntfy.md @@ -47,6 +47,11 @@ Then reload the configuration. > [`global-config`](../../global-config.rsc) (the one without `-overlay`) to > your local `global-config-overlay` and modify it to your specific needs. +Using a paid account or running a server on-premises allows to add additional +basic authentication. Configure `NtfyServerUser` and `NtfyServerPass` for this. +Even authentication via access token is possible, adding it as password with +a blank username. + Usage and invocation -------------------- diff --git a/global-config.rsc b/global-config.rsc index f393abb..6a37c0c 100644 --- a/global-config.rsc +++ b/global-config.rsc @@ -56,6 +56,8 @@ # install the module: # $ScriptInstallUpdate mod/notification-ntfy :global NtfyServer "ntfy.sh"; +:global NtfyServerUser []; +:global NtfyServerPass []; :global NtfyTopic ""; # It is possible to override e-mail, Telegram, Matrix and Ntfy setting diff --git a/global-functions.rsc b/global-functions.rsc index abb9e22..8f2f179 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -12,7 +12,7 @@ :local ScriptName [ :jobname ]; # expected configuration version -:global ExpectedConfigVersion 126; +:global ExpectedConfigVersion 127; # global variables not to be changed by user :global GlobalFunctionsReady false; diff --git a/mod/notification-ntfy.rsc b/mod/notification-ntfy.rsc index dc03903..ffe0c50 100644 --- a/mod/notification-ntfy.rsc +++ b/mod/notification-ntfy.rsc @@ -38,7 +38,8 @@ :if ([ :typeof $Message ] = "array" ) do={ :do { /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ - ($Message->"url") http-header-field=($Message->"headers") http-data=($Message->"text") as-value; + http-header-field=($Message->"headers") http-data=($Message->"text") \ + ($Message->"url") user=($Message->"user") password=($Message->"pass") as-value; :set ($NtfyQueue->$Id); } on-error={ $LogPrint debug $0 ("Sending queued Ntfy message failed."); @@ -62,6 +63,10 @@ :global NtfyQueue; :global NtfyServer; :global NtfyServerOverride; + :global NtfyServerPass; + :global NtfyServerPassOverride; + :global NtfyServerUser; + :global NtfyServerUserOverride; :global NtfyTopic; :global NtfyTopicOverride; @@ -73,6 +78,8 @@ :global UrlEncode; :local Server [ $EitherOr ($NtfyServerOverride->($Notification->"origin")) $NtfyServer ]; + :local User [ $EitherOr ($NtfyServerUserOverride->($Notification->"origin")) $NtfyServerUser ]; + :local Pass [ $EitherOr ($NtfyServerPassOverride->($Notification->"origin")) $NtfyServerPass ]; :local Topic [ $EitherOr ($NtfyTopicOverride->($Notification->"origin")) $NtfyTopic ]; :if ([ :len $Topic ] = 0) do={ @@ -95,7 +102,7 @@ } } /tool/fetch check-certificate=yes-without-crl output=none http-method=post \ - $Url http-header-field=$Headers http-data=$Text as-value; + http-header-field=$Headers http-data=$Text $Url user=$User password=$Pass as-value; } on-error={ $LogPrint info $0 ("Failed sending ntfy notification! Queuing..."); @@ -105,7 +112,8 @@ :set Text ($Text . "\n" . [ $SymbolForNotification "alarm-clock" ] . \ "This message was queued since " . [ /system/clock/get date ] . " " . \ [ /system/clock/get time ] . " and may be obsolete."); - :set ($NtfyQueue->[ :len $NtfyQueue ]) { url=$Url; headers=$Headers; text=$Text }; + :set ($NtfyQueue->[ :len $NtfyQueue ]) \ + { url=$Url; user=$User; pass=$Pass; 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;"); diff --git a/news-and-changes.rsc b/news-and-changes.rsc index 2b04c29..8ddeb91 100644 --- a/news-and-changes.rsc +++ b/news-and-changes.rsc @@ -51,6 +51,7 @@ 124="Added support for links in 'netwatch-notify', these are added below the formatted notification text."; 125=("April's Fool! " . [ $SymbolForNotification "smiley-partying-face" ] . "Well, you missed it... - no charge nor fees. (Anyway... Donations are much appreciated, " . [ $SymbolForNotification "smiley-smiling-face" ] . "thanks!)"); 126="Made 'telegram-chat' capable of handling large command output. Telegram messages still limit the size, so it is truncated now."; + 127="Added support for authentication to Ntfy notification module."; }; # Migration steps to be applied on script updates |