LunaSea Support

This commit is contained in:
Niyas 2021-07-31 10:33:20 +05:30 committed by GitHub
parent 67a4e949a2
commit ab1fe2e2d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -235,6 +235,41 @@ class Notification {
return Notification.apprise(notification, msg) return Notification.apprise(notification, msg)
} else if (notification.type === "lunasea") {
let lunaseadevice = "https://notify.lunasea.app/v1/custom/device/"+notification.lunaseaDevice
try {
if (heartbeatJSON == null) {
let testdata = {
"title": "Uptime Kuma Alert",
"body": "Testing Successful."
}
await axios.post(lunaseadevice, testdata)
return okMsg;
}
if (heartbeatJSON["status"] == 0) {
let downdata = {
"title": "UptimeKuma Alert:" +monitorJSON["name"],
"body": "[🔴 Down]"+heartbeatJSON['msg']+ "\nTime (UTC):" + heartbeatJSON["time"]
}
await axios.post(lunaseadevice, downdata)
return okMsg;
}
if (heartbeatJSON["status"] == 1) {
let updata = {
"title": "UptimeKuma Alert:" +monitorJSON["name"],
"body": "[✅ Up]"+heartbeatJSON['msg']+ "\nTime (UTC):" + heartbeatJSON["time"]
}
await axios.post(lunaseadevice, updata)
return okMsg;
}
} catch (error) {
throwGeneralAxiosError(error)
}
} else { } else {
throw new Error("Notification type is not supported") throw new Error("Notification type is not supported")
} }