diff --git a/server/notification-providers/gorush.js b/server/notification-providers/gorush.js new file mode 100644 index 00000000..58da5525 --- /dev/null +++ b/server/notification-providers/gorush.js @@ -0,0 +1,42 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class Gorush extends NotificationProvider { + + name = "gorush"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + let platformMapping = { + "ios": 1, + "android": 2, + "huawei": 3, + }; + + try { + let data = { + "notifications": [ + { + "tokens": [notification.gorushDeviceToken], + "platform": platformMapping[notification.gorushPlatform], + "message": msg, + // Optional + "title": notification.gorushTitle, + "priority": notification.gorushPriority, + "retry": parseInt(notification.gorushRetry) || 0, + "topic": notification.gorushTopic, + } + ] + }; + let config = {}; + + await axios.post(`${notification.gorushServerURL}/api/push`, data, config); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Gorush; diff --git a/server/notification.js b/server/notification.js index dc3ea796..3b12fbcd 100644 --- a/server/notification.js +++ b/server/notification.js @@ -27,6 +27,7 @@ const SerwerSMS = require("./notification-providers/serwersms"); const Stackfield = require("./notification-providers/stackfield"); const WeCom = require("./notification-providers/wecom"); const GoogleChat = require("./notification-providers/google-chat"); +const Gorush = require("./notification-providers/gorush"); const Alerta = require("./notification-providers/alerta"); class Notification { @@ -67,6 +68,7 @@ class Notification { new Stackfield(), new WeCom(), new GoogleChat(), + new Gorush(), new Alerta(), ]; diff --git a/src/components/notifications/Gorush.vue b/src/components/notifications/Gorush.vue new file mode 100644 index 00000000..b53be2d2 --- /dev/null +++ b/src/components/notifications/Gorush.vue @@ -0,0 +1,51 @@ + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 599ea4db..9b6768cf 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -26,6 +26,7 @@ import SerwerSMS from "./SerwerSMS.vue"; import Stackfield from './Stackfield.vue'; import WeCom from "./WeCom.vue"; import GoogleChat from "./GoogleChat.vue"; +import Gorush from "./Gorush.vue"; import Alerta from "./Alerta.vue"; /** @@ -62,6 +63,7 @@ const NotificationFormList = { "stackfield": Stackfield, "WeCom": WeCom, "GoogleChat": GoogleChat, + "gorush": Gorush, "alerta": Alerta, }; diff --git a/src/languages/en.js b/src/languages/en.js index 6ed6cc50..9ab89717 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -361,6 +361,7 @@ export default { smtpDkimHashAlgo: "Hash Algorithm (Optional)", smtpDkimheaderFieldNames: "Header Keys to sign (Optional)", smtpDkimskipFields: "Header Keys not to sign (Optional)", + gorush: "Gorush", alerta: 'Alerta', alertaApiEndpoint: 'API Endpoint', alertaEnvironment: 'Environment',