mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-20 18:55:49 +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;
|
Reference in New Issue
Block a user