From 0606d3fed9c2c7db6f1dba1204ddb014c5ec224d Mon Sep 17 00:00:00 2001 From: trivernis Date: Fri, 16 Jun 2023 17:18:57 +0200 Subject: [PATCH] Add hostname to messages published by cntfy --- cntfy.nu | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/cntfy.nu b/cntfy.nu index f820a53..3745af2 100755 --- a/cntfy.nu +++ b/cntfy.nu @@ -33,19 +33,25 @@ def subcommands [] { # Publishes a message export def `main publish` [ topic: string - body: any + message: string --title: string - --priority: string - --tags: string + --priority: number + --tags: list + --actions: list + --icon: string ] { - let headers = ( [] - | append [Title $title] - | append [Priority $priority] - | append [Tags $tags] - ) - let cfg = ( get_config ) - http put -u $cfg.username -p $cfg.password -H $headers ( build_url $topic ) $body + + let request_body = ({ + topic: $topic + title: $title + message: $message + tags: ( $tags | append ( hostname ) ) + priority: $priority + actions: $actions + icon: $icon + } | to json ) + http put -u $cfg.username -p $cfg.password $cfg.url $request_body } def get_config [] { @@ -66,7 +72,3 @@ def get_config [] { ( $cfg_path | open ) } - -def build_url [topic: string] { - $"https://ntfy.trivernis.dev/($topic)" -} \ No newline at end of file