mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-01 19:32:34 +02:00

- 在 notification.js 中添加 PushPlusPlus 通知提供商 - 在 NotificationDialog.vue 中添加 PushPlusPlus 选项 - 在 notifications/index.js 中导入并注册 PushPlusPlus 组件
42 lines
No EOL
1.4 KiB
JavaScript
42 lines
No EOL
1.4 KiB
JavaScript
const NotificationProvider = require("./notification-provider");
|
|
const axios = require("axios");
|
|
const { DOWN, UP } = require("../../src/util");
|
|
|
|
class PushPlusPlus extends NotificationProvider {
|
|
name = "PushPlusPlus";
|
|
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
|
const okMsg = "Sent Successfully.";
|
|
const url = `https://pushplus.plus/send`;
|
|
try {
|
|
await axios.post(notification.pushPlusPlusToken, {
|
|
"title": this.checkStatus(heartbeatJSON, monitorJSON),
|
|
"content": msg,
|
|
});
|
|
|
|
return okMsg;
|
|
|
|
} catch (error) {
|
|
this.throwGeneralAxiosError(error);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the formatted title for message
|
|
* @param {?object} heartbeatJSON Heartbeat details (For Up/Down only)
|
|
* @param {?object} monitorJSON Monitor details (For Up/Down only)
|
|
* @returns {string} Formatted title
|
|
*/
|
|
checkStatus(heartbeatJSON, monitorJSON) {
|
|
let title = "UptimeKuma Message";
|
|
if (heartbeatJSON != null && heartbeatJSON["status"] === UP) {
|
|
title = "UptimeKuma Monitor Up " + monitorJSON["name"];
|
|
}
|
|
if (heartbeatJSON != null && heartbeatJSON["status"] === DOWN) {
|
|
title = "UptimeKuma Monitor Down " + monitorJSON["name"];
|
|
}
|
|
return title;
|
|
}
|
|
}
|
|
|
|
module.exports = PushPlusPlus; |