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