diff --git a/server/notification-providers/postrequest.js b/server/notification-providers/postrequest.js new file mode 100644 index 000000000..47ae3599f --- /dev/null +++ b/server/notification-providers/postrequest.js @@ -0,0 +1,30 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class PostRequest extends NotificationProvider { + name = "PostRequest"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + const url = notification.postrequestURL; + + try { + let config = { + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notification.postrequestToken, + } + }; + + let data = notification.postrequestBody; + + let resp = await axios.post(url, data, config); + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = PostRequest; diff --git a/server/notification.js b/server/notification.js index e7977eb4a..3f703c1f1 100644 --- a/server/notification.js +++ b/server/notification.js @@ -69,6 +69,7 @@ const Cellsynt = require("./notification-providers/cellsynt"); const Onesender = require("./notification-providers/onesender"); const Wpush = require("./notification-providers/wpush"); const SendGrid = require("./notification-providers/send-grid"); +const PostRequest = require("./notification-providers/postrequest"); class Notification { @@ -154,7 +155,8 @@ class Notification { new GtxMessaging(), new Cellsynt(), new Wpush(), - new SendGrid() + new SendGrid(), + new PostRequest() ]; for (let item of list) { if (! item.name) { @@ -181,6 +183,7 @@ class Notification { if (this.providerList[notification.type]) { return this.providerList[notification.type].send(notification, msg, monitorJSON, heartbeatJSON); } else { + console.log(notification.type); throw new Error("Notification type is not supported"); } } diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index f6d728029..46f13828b 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -165,7 +165,8 @@ export default { "whapi": "WhatsApp (Whapi)", "gtxmessaging": "GtxMessaging", "Cellsynt": "Cellsynt", - "SendGrid": "SendGrid" + "SendGrid": "SendGrid", + "PostRequest": "PostRequest", }; // Put notifications here if it's not supported in most regions or its documentation is not in English diff --git a/src/components/notifications/PostRequest.vue b/src/components/notifications/PostRequest.vue new file mode 100644 index 000000000..ff0d2ce34 --- /dev/null +++ b/src/components/notifications/PostRequest.vue @@ -0,0 +1,14 @@ + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index efa2af5c4..f23becd0b 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -67,6 +67,7 @@ import Cellsynt from "./Cellsynt.vue"; import WPush from "./WPush.vue"; import SIGNL4 from "./SIGNL4.vue"; import SendGrid from "./SendGrid.vue"; +import PostRequest from "./PostRequest.vue"; /** * Manage all notification form. @@ -142,6 +143,7 @@ const NotificationFormList = { "Cellsynt": Cellsynt, "WPush": WPush, "SendGrid": SendGrid, + "PostRequest": PostRequest, }; export default NotificationFormList; diff --git a/src/lang/de-DE.json b/src/lang/de-DE.json index 9102d8e94..da52c083b 100644 --- a/src/lang/de-DE.json +++ b/src/lang/de-DE.json @@ -1098,5 +1098,6 @@ "rabbitmqNodesDescription": "Gib die URL für die RabbitMQ-Verwaltungsknoten einschließlich Protokoll und Port ein. Beispiel: {0}", "rabbitmqNodesInvalid": "Benutze eine vollständig qualifizierte URL (beginnend mit 'http') für RabbitMQ-Knoten.", "rabbitmqHelpText": "Um den Monitor zu benutzen, musst du das Management Plugin in deinem RabbitMQ-Setup aktivieren. Weitere Informationen siehe {rabitmq_documentation}.", - "aboutSlackUsername": "Ändert den Anzeigenamen des Absenders. Wenn du jemanden erwähnen möchtest, füge ihn stattdessen in den Namen ein." + "aboutSlackUsername": "Ändert den Anzeigenamen des Absenders. Wenn du jemanden erwähnen möchtest, füge ihn stattdessen in den Namen ein.", + "Bearer Token": "Bearer Token" } diff --git a/src/lang/en.json b/src/lang/en.json index e215f1031..62553ac26 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -550,6 +550,7 @@ "Number": "Number", "Recipients": "Recipients", "Access Token": "Access Token", + "Bearer Token": "Bearer Token", "Channel access token": "Channel access token", "Channel access token (Long-lived)": "Channel access token (Long-lived)", "Line Developers Console": "Line Developers Console",