|
|
@ -15,7 +15,7 @@ class Notification {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error)
|
|
|
|
console.error(error)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -31,7 +31,7 @@ class Notification {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error)
|
|
|
|
console.error(error)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -61,7 +61,7 @@ class Notification {
|
|
|
|
await axios.post(notification.webhookURL, finalData, config)
|
|
|
|
await axios.post(notification.webhookURL, finalData, config)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error)
|
|
|
|
console.error(error)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -106,7 +106,7 @@ class Notification {
|
|
|
|
await axios.post(notification.discordWebhookUrl, data)
|
|
|
|
await axios.post(notification.discordWebhookUrl, data)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch(error) {
|
|
|
|
} catch(error) {
|
|
|
|
console.log(error)
|
|
|
|
console.error(error)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -122,20 +122,25 @@ class Notification {
|
|
|
|
await axios.post(notification.signalURL, data, config)
|
|
|
|
await axios.post(notification.signalURL, data, config)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error)
|
|
|
|
console.error(error)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (notification.type === "slack") {
|
|
|
|
} else if (notification.type === "slack") {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (heartbeatJSON == null) {
|
|
|
|
if (heartbeatJSON == null) {
|
|
|
|
let data = {'text': "Uptime Kuma Slack testing successful."}
|
|
|
|
let data = {'text': "Uptime Kuma Slack testing successful.", 'channel': notification.slackchannel, 'username': notification.slackusername, 'icon_emoji': notification.slackiconemo}
|
|
|
|
await axios.post(notification.slackwebhookURL, data)
|
|
|
|
await axios.post(notification.slackwebhookURL, data)
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const time = heartbeatJSON["time"];
|
|
|
|
const time = heartbeatJSON["time"];
|
|
|
|
let data = {
|
|
|
|
let data = {
|
|
|
|
|
|
|
|
"text": "Uptime Kuma Alert",
|
|
|
|
|
|
|
|
"channel":notification.slackchannel,
|
|
|
|
|
|
|
|
"username": notification.slackusername,
|
|
|
|
|
|
|
|
"icon_emoji": notification.slackiconemo,
|
|
|
|
"blocks": [{
|
|
|
|
"blocks": [{
|
|
|
|
"type": "header",
|
|
|
|
"type": "header",
|
|
|
|
"text": {
|
|
|
|
"text": {
|
|
|
@ -165,7 +170,7 @@ class Notification {
|
|
|
|
"text": "Visit Uptime Kuma",
|
|
|
|
"text": "Visit Uptime Kuma",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"value": "Uptime-Kuma",
|
|
|
|
"value": "Uptime-Kuma",
|
|
|
|
"url": notification.slackbutton
|
|
|
|
"url": notification.slackbutton || "https://github.com/louislam/uptime-kuma"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -173,6 +178,35 @@ class Notification {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await axios.post(notification.slackwebhookURL, data)
|
|
|
|
await axios.post(notification.slackwebhookURL, data)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (notification.type === "pushover") {
|
|
|
|
|
|
|
|
var pushoverlink = 'https://api.pushover.net/1/messages.json'
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (heartbeatJSON == null) {
|
|
|
|
|
|
|
|
let data = {'message': "<b>Uptime Kuma Pushover testing successful.</b>",
|
|
|
|
|
|
|
|
'user': notification.pushoveruserkey, 'token': notification.pushoverapptoken, 'sound':notification.pushoversounds,
|
|
|
|
|
|
|
|
'priority': notification.pushoverpriority, 'title':notification.pushovertitle, 'retry': "30", 'expire':"3600", 'html': 1}
|
|
|
|
|
|
|
|
let res = await axios.post(pushoverlink, data)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let data = {
|
|
|
|
|
|
|
|
"message": "<b>Uptime Kuma Alert</b>\n\n<b>Message</b>:" +msg + '\n<b>Time (UTC)</b>:' +time,
|
|
|
|
|
|
|
|
"user":notification.pushoveruserkey,
|
|
|
|
|
|
|
|
"token": notification.pushoverapptoken,
|
|
|
|
|
|
|
|
"sound": notification.pushoversounds,
|
|
|
|
|
|
|
|
"priority": notification.pushoverpriority,
|
|
|
|
|
|
|
|
"title": notification.pushovertitle,
|
|
|
|
|
|
|
|
"retry": "30",
|
|
|
|
|
|
|
|
"expire": "3600",
|
|
|
|
|
|
|
|
"html": 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let res = await axios.post(pushoverlink, data)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error)
|
|
|
|
console.log(error)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|