mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-10-04 14:39:19 +08:00
feat: Support SMSPlanet notification provider (#5800)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
40
server/notification-providers/sms-planet.js
Normal file
40
server/notification-providers/sms-planet.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
|
||||
class SMSPlanet extends NotificationProvider {
|
||||
name = "SMSPlanet";
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
const url = "https://api2.smsplanet.pl/sms";
|
||||
|
||||
try {
|
||||
let config = {
|
||||
headers: {
|
||||
"Authorization": "Bearer " + notification.smsplanetApiToken,
|
||||
"content-type": "multipart/form-data"
|
||||
}
|
||||
};
|
||||
|
||||
let data = {
|
||||
"from": notification.smsplanetSenderName,
|
||||
"to": notification.smsplanetPhoneNumbers,
|
||||
"msg": msg.replace(/🔴/, "❌")
|
||||
};
|
||||
|
||||
let response = await axios.post(url, data, config);
|
||||
if (!response.data?.messageId) {
|
||||
throw new Error(response.data?.errorMsg ?? "SMSPlanet server did not respond with the expected result");
|
||||
}
|
||||
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SMSPlanet;
|
@@ -72,6 +72,7 @@ const Onesender = require("./notification-providers/onesender");
|
||||
const Wpush = require("./notification-providers/wpush");
|
||||
const SendGrid = require("./notification-providers/send-grid");
|
||||
const YZJ = require("./notification-providers/yzj");
|
||||
const SMSPlanet = require("./notification-providers/sms-planet");
|
||||
|
||||
class Notification {
|
||||
|
||||
@@ -160,7 +161,8 @@ class Notification {
|
||||
new Cellsynt(),
|
||||
new Wpush(),
|
||||
new SendGrid(),
|
||||
new YZJ()
|
||||
new YZJ(),
|
||||
new SMSPlanet(),
|
||||
];
|
||||
for (let item of list) {
|
||||
if (! item.name) {
|
||||
|
Reference in New Issue
Block a user