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.load(it)
|
||||||
prop.setProperty("botToken", "YourTokenHere")
|
prop.setProperty("botToken", "YourTokenHere")
|
||||||
prop.setProperty("instance", "instance.domain")
|
prop.setProperty("instance", "instance.domain")
|
||||||
|
prop.setProperty("ntfyEndpoint", "ntfy.example.com/topic")
|
||||||
prop.setProperty("superSecret", "secretKey")
|
prop.setProperty("superSecret", "secretKey")
|
||||||
}
|
}
|
||||||
val out: OutputStream = FileOutputStream(confFile)
|
val out: OutputStream = FileOutputStream(confFile)
|
||||||
|
@ -34,5 +35,6 @@ class Config {
|
||||||
|
|
||||||
val botToken: String = (prop.getProperty("botToken"))
|
val botToken: String = (prop.getProperty("botToken"))
|
||||||
val instanceDomain: String = (prop.getProperty("instance"))
|
val instanceDomain: String = (prop.getProperty("instance"))
|
||||||
|
val ntfyEndpoint: String = (prop.getProperty("ntfyEndpoint"))
|
||||||
val superSecret: String = (prop.getProperty("superSecret"))
|
val superSecret: String = (prop.getProperty("superSecret"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,14 @@ suspend fun makePost(
|
||||||
// Send a ntfy message
|
// Send a ntfy message
|
||||||
suspend fun ntfyMsg(
|
suspend fun ntfyMsg(
|
||||||
client: HttpClient,
|
client: HttpClient,
|
||||||
|
endpoint: String,
|
||||||
title: String,
|
title: String,
|
||||||
message: String,
|
message: String,
|
||||||
attach: String,
|
attach: String,
|
||||||
click: String,
|
click: String,
|
||||||
) {
|
) {
|
||||||
val message: HttpResponse =
|
val message: HttpResponse =
|
||||||
client.post("https://ntfy.ouroboros.group/pushy") {
|
client.post("https://" + endpoint) {
|
||||||
headers {
|
headers {
|
||||||
append("Title", title)
|
append("Title", title)
|
||||||
append("Attach", attach)
|
append("Attach", attach)
|
||||||
|
|
|
@ -141,7 +141,7 @@ fun Application.configureRouting(client: HttpClient) {
|
||||||
val click = formParameters["Click"].toString()
|
val click = formParameters["Click"].toString()
|
||||||
call.response.status(HttpStatusCode(201, "Received..."))
|
call.response.status(HttpStatusCode(201, "Received..."))
|
||||||
call.respondText("Received:: Title: $title, Message: $message, Attachment: $attach, Click: $click")
|
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)
|
storeMessage(title, message, attach, click)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue