mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-08 19:01:22 +08:00
Add gtxmessaging Notification Support (#4481)
Signed-off-by: Christoph Fichtmüller <cf@cfichtmueller.com> Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
committed by
GitHub
parent
e927327bad
commit
49b6dacb4d
33
server/notification-providers/gtx-messaging.js
Normal file
33
server/notification-providers/gtx-messaging.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
|
||||
class GtxMessaging extends NotificationProvider {
|
||||
name = "gtxmessaging";
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
// The UP/DOWN symbols will be replaced with `???` by gtx-messaging
|
||||
const text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", "");
|
||||
|
||||
try {
|
||||
const data = new URLSearchParams();
|
||||
data.append("from", notification.gtxMessagingFrom.trim());
|
||||
data.append("to", notification.gtxMessagingTo.trim());
|
||||
data.append("text", text);
|
||||
|
||||
const url = `https://rest.gtx-messaging.net/smsc/sendsms/${notification.gtxMessagingApiKey}/json`;
|
||||
|
||||
await axios.post(url, data);
|
||||
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GtxMessaging;
|
Reference in New Issue
Block a user