|
|
@ -33,19 +33,25 @@ def subcommands [] {
|
|
|
|
# Publishes a message
|
|
|
|
# Publishes a message
|
|
|
|
export def `main publish` [
|
|
|
|
export def `main publish` [
|
|
|
|
topic: string
|
|
|
|
topic: string
|
|
|
|
body: any
|
|
|
|
message: string
|
|
|
|
--title: string
|
|
|
|
--title: string
|
|
|
|
--priority: string
|
|
|
|
--priority: number
|
|
|
|
--tags: string
|
|
|
|
--tags: list<string>
|
|
|
|
|
|
|
|
--actions: list<any>
|
|
|
|
|
|
|
|
--icon: string
|
|
|
|
] {
|
|
|
|
] {
|
|
|
|
let headers = ( []
|
|
|
|
|
|
|
|
| append [Title $title]
|
|
|
|
|
|
|
|
| append [Priority $priority]
|
|
|
|
|
|
|
|
| append [Tags $tags]
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cfg = ( get_config )
|
|
|
|
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 [] {
|
|
|
|
def get_config [] {
|
|
|
@ -66,7 +72,3 @@ def get_config [] {
|
|
|
|
|
|
|
|
|
|
|
|
( $cfg_path | open )
|
|
|
|
( $cfg_path | open )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def build_url [topic: string] {
|
|
|
|
|
|
|
|
$"https://ntfy.trivernis.dev/($topic)"
|
|
|
|
|
|
|
|
}
|
|
|
|
|