make ntfy endpoint configurable
This commit is contained in:
parent
1d57537c87
commit
9d9fc3fbf2
3 changed files with 5 additions and 2 deletions
|
@ -25,6 +25,7 @@ class Config {
|
|||
prop.load(it)
|
||||
prop.setProperty("botToken", "YourTokenHere")
|
||||
prop.setProperty("instance", "instance.domain")
|
||||
prop.setProperty("ntfyEndpoint", "ntfy.example.com/topic")
|
||||
prop.setProperty("superSecret", "secretKey")
|
||||
}
|
||||
val out: OutputStream = FileOutputStream(confFile)
|
||||
|
@ -34,5 +35,6 @@ class Config {
|
|||
|
||||
val botToken: String = (prop.getProperty("botToken"))
|
||||
val instanceDomain: String = (prop.getProperty("instance"))
|
||||
val ntfyEndpoint: String = (prop.getProperty("ntfyEndpoint"))
|
||||
val superSecret: String = (prop.getProperty("superSecret"))
|
||||
}
|
||||
|
|
|
@ -35,13 +35,14 @@ suspend fun makePost(
|
|||
// Send a ntfy message
|
||||
suspend fun ntfyMsg(
|
||||
client: HttpClient,
|
||||
endpoint: String,
|
||||
title: String,
|
||||
message: String,
|
||||
attach: String,
|
||||
click: String,
|
||||
) {
|
||||
val message: HttpResponse =
|
||||
client.post("https://ntfy.ouroboros.group/pushy") {
|
||||
client.post("https://" + endpoint) {
|
||||
headers {
|
||||
append("Title", title)
|
||||
append("Attach", attach)
|
||||
|
|
|
@ -141,7 +141,7 @@ fun Application.configureRouting(client: HttpClient) {
|
|||
val click = formParameters["Click"].toString()
|
||||
call.response.status(HttpStatusCode(201, "Received..."))
|
||||
call.respondText("Received:: Title: $title, Message: $message, Attachment: $attach, Click: $click")
|
||||
ntfyMsg(client, title, message, attach, click)
|
||||
ntfyMsg(client, Config().ntfyEndpoint, title, message, attach, click)
|
||||
storeMessage(title, message, attach, click)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue