From dda40610c7ae307681429274430d48b9049c1933 Mon Sep 17 00:00:00 2001 From: Erlaan Date: Fri, 11 Oct 2024 11:07:34 +0200 Subject: [PATCH] feat: new notification provider `46elks` (#5184) Co-authored-by: Frank Elsinga --- server/notification-providers/46elks.js | 35 ++++++++++++++++++ server/notification.js | 2 ++ src/components/NotificationDialog.vue | 1 + src/components/notifications/46elks.vue | 48 +++++++++++++++++++++++++ src/components/notifications/index.js | 2 ++ src/lang/en.json | 6 +++- 6 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 server/notification-providers/46elks.js create mode 100644 src/components/notifications/46elks.vue diff --git a/server/notification-providers/46elks.js b/server/notification-providers/46elks.js new file mode 100644 index 000000000..4b15e9fad --- /dev/null +++ b/server/notification-providers/46elks.js @@ -0,0 +1,35 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class Elks extends NotificationProvider { + name = "Elks"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + const url = "https://api.46elks.com/a1/sms"; + + try { + let data = new URLSearchParams(); + data.append("from", notification.elksFromNumber); + data.append("to", notification.elksToNumber ); + data.append("message", msg); + + const config = { + headers: { + "Authorization": "Basic " + Buffer.from(`${notification.elksUsername}:${notification.elksAuthToken}`).toString("base64") + } + }; + + await axios.post(url, data, config); + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Elks; diff --git a/server/notification.js b/server/notification.js index 60eae4d73..26daeb042 100644 --- a/server/notification.js +++ b/server/notification.js @@ -11,6 +11,7 @@ const CallMeBot = require("./notification-providers/call-me-bot"); const SMSC = require("./notification-providers/smsc"); const DingDing = require("./notification-providers/dingding"); const Discord = require("./notification-providers/discord"); +const Elks = require("./notification-providers/46elks"); const Feishu = require("./notification-providers/feishu"); const FreeMobile = require("./notification-providers/freemobile"); const GoogleChat = require("./notification-providers/google-chat"); @@ -95,6 +96,7 @@ class Notification { new SMSC(), new DingDing(), new Discord(), + new Elks(), new Feishu(), new FreeMobile(), new GoogleChat(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 864cbf5f4..ec86d15f8 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -118,6 +118,7 @@ export default { "clicksendsms": "ClickSend SMS", "CallMeBot": "CallMeBot (WhatsApp, Telegram Call, Facebook Messanger)", "discord": "Discord", + "Elks": "46elks", "GoogleChat": "Google Chat (Google Workspace)", "gorush": "Gorush", "gotify": "Gotify", diff --git a/src/components/notifications/46elks.vue b/src/components/notifications/46elks.vue new file mode 100644 index 000000000..d29655bd5 --- /dev/null +++ b/src/components/notifications/46elks.vue @@ -0,0 +1,48 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index e5df6fe4e..35a3a920a 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -9,6 +9,7 @@ import CallMeBot from "./CallMeBot.vue"; import SMSC from "./SMSC.vue"; import DingDing from "./DingDing.vue"; import Discord from "./Discord.vue"; +import Elks from "./46elks.vue"; import Feishu from "./Feishu.vue"; import FreeMobile from "./FreeMobile.vue"; import GoogleChat from "./GoogleChat.vue"; @@ -82,6 +83,7 @@ const NotificationFormList = { "smsc": SMSC, "DingDing": DingDing, "discord": Discord, + "Elks": Elks, "Feishu": Feishu, "FreeMobile": FreeMobile, "GoogleChat": GoogleChat, diff --git a/src/lang/en.json b/src/lang/en.json index cf0836d98..c07e06fab 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1047,5 +1047,9 @@ "Pop":"Pop", "Custom sound to override default notification sound": "Custom sound to override default notification sound", "Time Sensitive (iOS Only)": "Time Sensitive (iOS Only)", - "Time sensitive notifications will be delivered immediately, even if the device is in do not disturb mode.": "Time sensitive notifications will be delivered immediately, even if the device is in do not disturb mode." + "Time sensitive notifications will be delivered immediately, even if the device is in do not disturb mode.": "Time sensitive notifications will be delivered immediately, even if the device is in do not disturb mode.", + "From":"From", + "Can be found on:": "Can be found on: {0}", + "The phone number of the recipient in E.164 format.": "The phone number of the recipient in E.164 format.", + "Either a text sender ID or a phone number in E.164 format if you want to be able to receive replies.":"Either a text sender ID or a phone number in E.164 format if you want to be able to receive replies." }