|
|
|
@ -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<string>
|
|
|
|
|
--actions: list<any>
|
|
|
|
|
--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)"
|
|
|
|
|
}
|