main #8

Closed
limepotato wants to merge 183 commits from main into blog-drafts
3 changed files with 5 additions and 2 deletions
Showing only changes of commit 9d9fc3fbf2 - Show all commits

View file

@ -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"))
} }

View file

@ -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)

View file

@ -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)
} }
} }