Kuma/server/notification-providers/pushplusplus.js
Teror Fox 6f72ddbb72
feat(notification): 新增 PushPlusPlus 通知支持
- 在 notification.js 中添加 PushPlusPlus 通知提供商
- 在 NotificationDialog.vue 中添加 PushPlusPlus 选项
- 在 notifications/index.js 中导入并注册 PushPlusPlus 组件
2025-03-22 13:40:19 +08:00

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;