mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-09 08:38:37 +08:00
New notification provider: SMS Partner API (#4769)
Co-authored-by: Nicolas Verlhiac <nicolas@novariom.com> Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
46
server/notification-providers/smspartner.js
Normal file
46
server/notification-providers/smspartner.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
|
||||
class SMSPartner extends NotificationProvider {
|
||||
name = "SMSPartner";
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
const url = "https://api.smspartner.fr/v1/send";
|
||||
|
||||
try {
|
||||
// smspartner does not support non ascii characters and only a maximum 639 characters
|
||||
let cleanMsg = msg.replace(/[^\x00-\x7F]/g, "").substring(0, 639);
|
||||
|
||||
let data = {
|
||||
"apiKey": notification.smspartnerApikey,
|
||||
"sender": notification.smspartnerSenderName.substring(0, 11),
|
||||
"phoneNumbers": notification.smspartnerPhoneNumber,
|
||||
"message": cleanMsg,
|
||||
};
|
||||
|
||||
let config = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"cache-control": "no-cache",
|
||||
"Accept": "application/json",
|
||||
}
|
||||
};
|
||||
|
||||
let resp = await axios.post(url, data, config);
|
||||
|
||||
if (resp.data.success !== true) {
|
||||
throw Error(`Api returned ${resp.data.response.status}.`);
|
||||
}
|
||||
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SMSPartner;
|
@@ -43,6 +43,7 @@ const RocketChat = require("./notification-providers/rocket-chat");
|
||||
const SerwerSMS = require("./notification-providers/serwersms");
|
||||
const Signal = require("./notification-providers/signal");
|
||||
const Slack = require("./notification-providers/slack");
|
||||
const SMSPartner = require("./notification-providers/smspartner");
|
||||
const SMSEagle = require("./notification-providers/smseagle");
|
||||
const SMTP = require("./notification-providers/smtp");
|
||||
const Squadcast = require("./notification-providers/squadcast");
|
||||
@@ -123,6 +124,7 @@ class Notification {
|
||||
new SerwerSMS(),
|
||||
new Signal(),
|
||||
new SMSManager(),
|
||||
new SMSPartner(),
|
||||
new Slack(),
|
||||
new SMSEagle(),
|
||||
new SMTP(),
|
||||
|
Reference in New Issue
Block a user