mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-01 11:22:34 +02:00
Refactor SpugPush notification message formatting
This commit is contained in:
parent
ab68c35ad6
commit
fa3d1a55d7
1 changed files with 5 additions and 3 deletions
|
@ -12,16 +12,18 @@ class SpugPush extends NotificationProvider {
|
||||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
let okMsg = "Sent Successfully.";
|
let okMsg = "Sent Successfully.";
|
||||||
try {
|
try {
|
||||||
let formData = {msg}
|
let formData = {
|
||||||
|
msg
|
||||||
|
};
|
||||||
const apiUrl = `https://push.spug.cc/send/${notification.templateKey}`;
|
const apiUrl = `https://push.spug.cc/send/${notification.templateKey}`;
|
||||||
if (heartbeatJSON == null) {
|
if (heartbeatJSON == null) {
|
||||||
formData.title = "Uptime Kuma Message";
|
formData.title = "Uptime Kuma Message";
|
||||||
} else if (heartbeatJSON["status"] === UP) {
|
} else if (heartbeatJSON["status"] === UP) {
|
||||||
formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Up`;
|
formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Up`;
|
||||||
formData.msg = `[✅ Up] ${heartbeatJSON["msg"]}`
|
formData.msg = `[✅ Up] ${heartbeatJSON["msg"]}`;
|
||||||
} else if (heartbeatJSON["status"] === DOWN) {
|
} else if (heartbeatJSON["status"] === DOWN) {
|
||||||
formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Down`;
|
formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Down`;
|
||||||
formData.msg = `[🔴 Down] ${heartbeatJSON["msg"]}`
|
formData.msg = `[🔴 Down] ${heartbeatJSON["msg"]}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
await axios.post(apiUrl, formData);
|
await axios.post(apiUrl, formData);
|
||||||
|
|
Loading…
Add table
Reference in a new issue