diff --git a/server/notification-providers/discord.js b/server/notification-providers/discord.js index 971c26e5..881ad211 100644 --- a/server/notification-providers/discord.js +++ b/server/notification-providers/discord.js @@ -7,7 +7,7 @@ class Discord extends NotificationProvider { name = "discord"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { const discordDisplayName = notification.discordUsername || "Uptime Kuma"; diff --git a/server/notification-providers/gotify.js b/server/notification-providers/gotify.js index 9d2d55aa..08526189 100644 --- a/server/notification-providers/gotify.js +++ b/server/notification-providers/gotify.js @@ -6,7 +6,7 @@ class Gotify extends NotificationProvider { name = "gotify"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { if (notification.gotifyserverurl && notification.gotifyserverurl.endsWith("/")) { notification.gotifyserverurl = notification.gotifyserverurl.slice(0, -1); diff --git a/server/notification-providers/line.js b/server/notification-providers/line.js index 83096903..327696ed 100644 --- a/server/notification-providers/line.js +++ b/server/notification-providers/line.js @@ -7,7 +7,7 @@ class Line extends NotificationProvider { name = "line"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { let lineAPIUrl = "https://api.line.me/v2/bot/message/push"; let config = { diff --git a/server/notification-providers/lunasea.js b/server/notification-providers/lunasea.js index fb6cd236..c41f400e 100644 --- a/server/notification-providers/lunasea.js +++ b/server/notification-providers/lunasea.js @@ -7,7 +7,7 @@ class LunaSea extends NotificationProvider { name = "lunasea"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; let lunaseadevice = "https://notify.lunasea.app/v1/custom/device/" + notification.lunaseaDevice try { diff --git a/server/notification-providers/matrix.js b/server/notification-providers/matrix.js new file mode 100644 index 00000000..c1054fce --- /dev/null +++ b/server/notification-providers/matrix.js @@ -0,0 +1,45 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const Crypto = require("crypto"); +const { debug } = require("../../src/util"); + +class Matrix extends NotificationProvider { + name = "matrix"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + const size = 20; + const randomString = encodeURIComponent( + Crypto + .randomBytes(size) + .toString("base64") + .slice(0, size) + ); + + debug("Random String: " + randomString); + + const roomId = encodeURIComponent(notification.internalRoomId); + + debug("Matrix Room ID: " + roomId); + + try { + let config = { + headers: { + "Authorization": `Bearer ${notification.accessToken}`, + } + }; + let data = { + "msgtype": "m.text", + "body": msg + }; + + await axios.put(`${notification.homeserverUrl}/_matrix/client/r0/rooms/${roomId}/send/m.room.message/${randomString}`, data, config); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Matrix; diff --git a/server/notification-providers/mattermost.js b/server/notification-providers/mattermost.js index 97779435..d776284b 100644 --- a/server/notification-providers/mattermost.js +++ b/server/notification-providers/mattermost.js @@ -7,7 +7,7 @@ class Mattermost extends NotificationProvider { name = "mattermost"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { const mattermostUserName = notification.mattermostusername || "Uptime Kuma"; // If heartbeatJSON is null, assume we're testing. diff --git a/server/notification-providers/octopush.js b/server/notification-providers/octopush.js index 40273f9b..9d77aa5b 100644 --- a/server/notification-providers/octopush.js +++ b/server/notification-providers/octopush.js @@ -6,30 +6,54 @@ class Octopush extends NotificationProvider { name = "octopush"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { - let config = { - headers: { - "api-key": notification.octopushAPIKey, - "api-login": notification.octopushLogin, - "cache-control": "no-cache" - } - }; - let data = { - "recipients": [ - { - "phone_number": notification.octopushPhoneNumber + // Default - V2 + if (notification.octopushVersion == 2 || !notification.octopushVersion) { + let config = { + headers: { + "api-key": notification.octopushAPIKey, + "api-login": notification.octopushLogin, + "cache-control": "no-cache" } - ], - //octopush not supporting non ascii char - "text": msg.replace(/[^\x00-\x7F]/g, ""), - "type": notification.octopushSMSType, - "purpose": "alert", - "sender": notification.octopushSenderName - }; + }; + let data = { + "recipients": [ + { + "phone_number": notification.octopushPhoneNumber + } + ], + //octopush not supporting non ascii char + "text": msg.replace(/[^\x00-\x7F]/g, ""), + "type": notification.octopushSMSType, + "purpose": "alert", + "sender": notification.octopushSenderName + }; + await axios.post("https://api.octopush.com/v1/public/sms-campaign/send", data, config) + } else if (notification.octopushVersion == 1) { + let data = { + "user_login": notification.octopushDMLogin, + "api_key": notification.octopushDMAPIKey, + "sms_recipients": notification.octopushDMPhoneNumber, + "sms_sender": notification.octopushDMSenderName, + "sms_type": (notification.octopushDMSMSType == "sms_premium") ? "FR" : "XXX", + "transactional": "1", + //octopush not supporting non ascii char + "sms_text": msg.replace(/[^\x00-\x7F]/g, ""), + }; + + let config = { + headers: { + "cache-control": "no-cache" + }, + params: data + }; + await axios.post("https://www.octopush-dm.com/api/sms/json", {}, config) + } else { + throw new Error("Unknown Octopush version!"); + } - await axios.post("https://api.octopush.com/v1/public/sms-campaign/send", data, config) return okMsg; } catch (error) { this.throwGeneralAxiosError(error); diff --git a/server/notification-providers/pushbullet.js b/server/notification-providers/pushbullet.js index 0ed6f0fd..c7b824a2 100644 --- a/server/notification-providers/pushbullet.js +++ b/server/notification-providers/pushbullet.js @@ -8,7 +8,7 @@ class Pushbullet extends NotificationProvider { name = "pushbullet"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { let pushbulletUrl = "https://api.pushbullet.com/v2/pushes"; diff --git a/server/notification-providers/pushover.js b/server/notification-providers/pushover.js index 2133ca1c..77ef1a3f 100644 --- a/server/notification-providers/pushover.js +++ b/server/notification-providers/pushover.js @@ -6,7 +6,7 @@ class Pushover extends NotificationProvider { name = "pushover"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; let pushoverlink = "https://api.pushover.net/1/messages.json" try { diff --git a/server/notification-providers/pushy.js b/server/notification-providers/pushy.js index 431cf8c3..2bb89934 100644 --- a/server/notification-providers/pushy.js +++ b/server/notification-providers/pushy.js @@ -6,7 +6,7 @@ class Pushy extends NotificationProvider { name = "pushy"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { await axios.post(`https://api.pushy.me/push?api_key=${notification.pushyAPIKey}`, { diff --git a/server/notification-providers/rocket-chat.js b/server/notification-providers/rocket-chat.js index a9bd4009..25b0b945 100644 --- a/server/notification-providers/rocket-chat.js +++ b/server/notification-providers/rocket-chat.js @@ -9,7 +9,7 @@ class RocketChat extends NotificationProvider { name = "rocket.chat"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { if (heartbeatJSON == null) { let data = { diff --git a/server/notification-providers/signal.js b/server/notification-providers/signal.js index ba5f87f9..fee65754 100644 --- a/server/notification-providers/signal.js +++ b/server/notification-providers/signal.js @@ -6,7 +6,7 @@ class Signal extends NotificationProvider { name = "signal"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { let data = { diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index 271ee3dc..5132ba97 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -25,7 +25,7 @@ class Slack extends NotificationProvider { } async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { if (heartbeatJSON == null) { let data = { diff --git a/server/notification-providers/teams.js b/server/notification-providers/teams.js index 72409ffc..859af569 100644 --- a/server/notification-providers/teams.js +++ b/server/notification-providers/teams.js @@ -87,7 +87,7 @@ class Teams extends NotificationProvider { }; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { if (heartbeatJSON == null) { diff --git a/server/notification-providers/telegram.js b/server/notification-providers/telegram.js index f88dcf5d..54d33bfb 100644 --- a/server/notification-providers/telegram.js +++ b/server/notification-providers/telegram.js @@ -6,7 +6,7 @@ class Telegram extends NotificationProvider { name = "telegram"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { await axios.get(`https://api.telegram.org/bot${notification.telegramBotToken}/sendMessage`, { diff --git a/server/notification-providers/webhook.js b/server/notification-providers/webhook.js index 197e9f9f..9cb361f3 100644 --- a/server/notification-providers/webhook.js +++ b/server/notification-providers/webhook.js @@ -7,7 +7,7 @@ class Webhook extends NotificationProvider { name = "webhook"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { - let okMsg = "Sent Successfully. "; + let okMsg = "Sent Successfully."; try { let data = { diff --git a/server/notification.js b/server/notification.js index 13447241..207e0a37 100644 --- a/server/notification.js +++ b/server/notification.js @@ -5,6 +5,7 @@ const Gotify = require("./notification-providers/gotify"); const Line = require("./notification-providers/line"); const LunaSea = require("./notification-providers/lunasea"); const Mattermost = require("./notification-providers/mattermost"); +const Matrix = require("./notification-providers/matrix"); const Octopush = require("./notification-providers/octopush"); const Pushbullet = require("./notification-providers/pushbullet"); const Pushover = require("./notification-providers/pushover"); @@ -34,6 +35,7 @@ class Notification { new Line(), new LunaSea(), new Mattermost(), + new Matrix(), new Octopush(), new Pushbullet(), new Pushover(), diff --git a/src/components/Status.vue b/src/components/Status.vue index a4436e22..a3916adc 100644 --- a/src/components/Status.vue +++ b/src/components/Status.vue @@ -11,18 +11,18 @@ export default { computed: { color() { if (this.status === 0) { - return "danger" + return "danger"; } if (this.status === 1) { - return "primary" + return "primary"; } if (this.status === 2) { - return "warning" + return "warning"; } - return "secondary" + return "secondary"; }, text() { @@ -41,11 +41,11 @@ export default { return this.$t("Unknown"); }, }, -} +}; diff --git a/src/components/notifications/Matrix.vue b/src/components/notifications/Matrix.vue new file mode 100644 index 00000000..d1e973cd --- /dev/null +++ b/src/components/notifications/Matrix.vue @@ -0,0 +1,34 @@ + + + diff --git a/src/components/notifications/Octopush.vue b/src/components/notifications/Octopush.vue index fb0eb7f4..c75e87d3 100644 --- a/src/components/notifications/Octopush.vue +++ b/src/components/notifications/Octopush.vue @@ -1,4 +1,14 @@