Kuma/server/notification-providers/pushplusplus.js
Teror Fox 10fe953b52
fix(notification): 修正 PushPlusPlus 通知提供商的令牌使用错误
- 将 axios.post 请求的 URL 从 notification.pushPlusPlusToken 修改为 notification.PushPlusPlusToken
- 更新通知设置中的 PushPlusPlus 显示名称,使其首字母大写
- 在中文语言文件中添加 PushPlusPlus Token 相关翻译
2025-03-22 13:51:00 +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;