diff --git a/server/notification-providers/bitrix24.js b/server/notification-providers/bitrix24.js new file mode 100644 index 00000000..ba12126c --- /dev/null +++ b/server/notification-providers/bitrix24.js @@ -0,0 +1,31 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const { UP } = require("../../src/util"); + +class Bitrix24 extends NotificationProvider { + name = "Bitrix24"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + const params = { + user_id: notification.bitrix24UserID, + message: "[B]Uptime Kuma[/B]", + "ATTACH[COLOR]": (heartbeatJSON ?? {})["status"] === UP ? "#b73419" : "#67b518", + "ATTACH[BLOCKS][0][MESSAGE]": msg + }; + + await axios.get(`${notification.bitrix24WebhookURL}/im.notify.system.add.json`, { params }); + return okMsg; + + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Bitrix24; diff --git a/server/notification.js b/server/notification.js index 03bd368e..efb5e408 100644 --- a/server/notification.js +++ b/server/notification.js @@ -5,6 +5,7 @@ const AlertNow = require("./notification-providers/alertnow"); const AliyunSms = require("./notification-providers/aliyun-sms"); const Apprise = require("./notification-providers/apprise"); const Bark = require("./notification-providers/bark"); +const Bitrix24 = require("./notification-providers/bitrix24"); const ClickSendSMS = require("./notification-providers/clicksendsms"); const CallMeBot = require("./notification-providers/call-me-bot"); const SMSC = require("./notification-providers/smsc"); @@ -83,6 +84,7 @@ class Notification { new AliyunSms(), new Apprise(), new Bark(), + new Bitrix24(), new ClickSendSMS(), new CallMeBot(), new SMSC(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 09646d59..ebef7c9f 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -114,6 +114,7 @@ export default { "AlertNow": "AlertNow", "apprise": this.$t("apprise"), "Bark": "Bark", + "Bitrix24": "Bitrix24", "clicksendsms": "ClickSend SMS", "CallMeBot": "CallMeBot (WhatsApp, Telegram Call, Facebook Messanger)", "discord": "Discord", diff --git a/src/components/notifications/Bitrix24.vue b/src/components/notifications/Bitrix24.vue new file mode 100644 index 00000000..ac3dc312 --- /dev/null +++ b/src/components/notifications/Bitrix24.vue @@ -0,0 +1,24 @@ + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 52bebf83..cb6a96bf 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -3,6 +3,7 @@ import AlertNow from "./AlertNow.vue"; import AliyunSMS from "./AliyunSms.vue"; import Apprise from "./Apprise.vue"; import Bark from "./Bark.vue"; +import Bitrix24 from "./Bitrix24.vue"; import ClickSendSMS from "./ClickSendSMS.vue"; import CallMeBot from "./CallMeBot.vue"; import SMSC from "./SMSC.vue"; @@ -70,6 +71,7 @@ const NotificationFormList = { "AliyunSMS": AliyunSMS, "apprise": Apprise, "Bark": Bark, + "Bitrix24": Bitrix24, "clicksendsms": ClickSendSMS, "CallMeBot": CallMeBot, "smsc": SMSC, diff --git a/src/lang/en.json b/src/lang/en.json index d5ba62a5..d5cdec06 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -873,6 +873,9 @@ "noOrBadCertificate": "No/Bad Certificate", "gamedigGuessPort": "Gamedig: Guess Port", "gamedigGuessPortDescription": "The port used by Valve Server Query Protocol may be different from the client port. Try this if the monitor cannot connect to your server.", + "Bitrix24 Webhook URL": "Bitrix24 Webhook URL", + "wayToGetBitrix24Webhook": "You can create a webhook by following the steps at {0}", + "bitrix24SupportUserID": "Enter your user ID in Bitrix24. You can find out the ID from the link by going to the user's profile.", "Saved.": "Saved.", "authUserInactiveOrDeleted": "The user is inactive or deleted.", "authInvalidToken": "Invalid Token.",