From 8050cb8e99fed911f69b78b2d99994e2f180ef14 Mon Sep 17 00:00:00 2001 From: Philipp Bischoff Date: Sat, 11 Dec 2021 23:43:12 +0100 Subject: [PATCH 01/15] implement google chat notification type --- server/notification-providers/google-chat.js | 46 ++++++++++++++++++++ server/notification.js | 2 + src/components/notifications/GoogleChat.vue | 13 ++++++ src/components/notifications/index.js | 2 + 4 files changed, 63 insertions(+) create mode 100644 server/notification-providers/google-chat.js create mode 100644 src/components/notifications/GoogleChat.vue diff --git a/server/notification-providers/google-chat.js b/server/notification-providers/google-chat.js new file mode 100644 index 000000000..f73f4b5a5 --- /dev/null +++ b/server/notification-providers/google-chat.js @@ -0,0 +1,46 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const { setting } = require("../util-server"); +const { getMonitorRelativeURL } = require("../../src/util"); + +class GoogleChat extends NotificationProvider { + + name = "Google Chat"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + try { + // Google Chat message formatting: https://developers.google.com/chat/api/guides/message-formats/basic + + let textMsg = '' + if (heartbeatJSON && heartbeatJSON.status === UP) { + textMsg = `✅ Application is back online`; + } else { + textMsg = `🔴 Application went down`; + } + + if (monitorJSON && monitorJSON.name) { + textMsg += `\n*${monitorJSON.name}*`; + } + + textMsg += `\n${msg}`; + + const baseURL = await setting("primaryBaseURL"); + if (baseURL) { + textMsg += `\n${baseURL + getMonitorRelativeURL(monitorJSON.id)}`; + } + + const data = { + "text": textMsg, + }; + + await axios.post(notification.googleChatWebhookURL, data); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + + } +} + +module.exports = GoogleChat; diff --git a/server/notification.js b/server/notification.js index 3eb5f97bf..56a7e84d8 100644 --- a/server/notification.js +++ b/server/notification.js @@ -25,6 +25,7 @@ const DingDing = require("./notification-providers/dingding"); const Bark = require("./notification-providers/bark"); const SerwerSMS = require("./notification-providers/serwersms"); const Stackfield = require("./notification-providers/stackfield"); +const GoogleChat = require("./notification-providers/google-chat"); class Notification { @@ -62,6 +63,7 @@ class Notification { new Bark(), new SerwerSMS(), new Stackfield(), + new GoogleChat() ]; for (let item of list) { diff --git a/src/components/notifications/GoogleChat.vue b/src/components/notifications/GoogleChat.vue new file mode 100644 index 000000000..c19cae0de --- /dev/null +++ b/src/components/notifications/GoogleChat.vue @@ -0,0 +1,13 @@ + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 155a1ab26..678106102 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -24,6 +24,7 @@ import DingDing from "./DingDing.vue"; import Bark from "./Bark.vue"; import SerwerSMS from "./SerwerSMS.vue"; import Stackfield from './Stackfield.vue'; +import GoogleChat from './GoogleChat.vue'; /** * Manage all notification form. @@ -57,6 +58,7 @@ const NotificationFormList = { "Bark": Bark, "serwersms": SerwerSMS, "stackfield": Stackfield, + "Google Chat": GoogleChat } export default NotificationFormList From 83984668608fc9f3ff8e01f6c90fec4d8ecffff3 Mon Sep 17 00:00:00 2001 From: Philipp Bischoff Date: Sat, 11 Dec 2021 23:50:03 +0100 Subject: [PATCH 02/15] order notification types by name --- src/components/notifications/index.js | 44 +++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 678106102..a7c967edf 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -32,33 +32,33 @@ import GoogleChat from './GoogleChat.vue'; * @type { Record } */ const NotificationFormList = { - "telegram": Telegram, - "webhook": Webhook, - "smtp": STMP, - "discord": Discord, - "teams": Teams, - "signal": Signal, - "gotify": Gotify, - "slack": Slack, - "rocket.chat": RocketChat, - "pushover": Pushover, - "pushy": Pushy, - "octopush": Octopush, - "promosms": PromoSMS, - "clicksendsms": ClickSendSMS, - "lunasea": LunaSea, - "Feishu": Feishu, "AliyunSMS": AliyunSMS, "apprise": Apprise, - "pushbullet": Pushbullet, - "line": Line, - "mattermost": Mattermost, - "matrix": Matrix, - "DingDing": DingDing, "Bark": Bark, + "clicksendsms": ClickSendSMS, + "DingDing": DingDing, + "discord": Discord, + "smtp": STMP, + "Feishu": Feishu, + "Google Chat": GoogleChat, + "gotify": Gotify, + "line": Line, + "lunasea": LunaSea, + "matrix": Matrix, + "mattermost": Mattermost, + "octopush": Octopush, + "promosms": PromoSMS, + "pushbullet": Pushbullet, + "pushover": Pushover, + "pushy": Pushy, + "rocket.chat": RocketChat, "serwersms": SerwerSMS, + "signal": Signal, + "slack": Slack, "stackfield": Stackfield, - "Google Chat": GoogleChat + "teams": Teams, + "telegram": Telegram, + "webhook": Webhook } export default NotificationFormList From a71569379ea9bbab2360ed0b129865124721ebf3 Mon Sep 17 00:00:00 2001 From: Philipp Bischoff Date: Sun, 12 Dec 2021 00:01:12 +0100 Subject: [PATCH 03/15] add missing import --- server/notification-providers/google-chat.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/notification-providers/google-chat.js b/server/notification-providers/google-chat.js index f73f4b5a5..897dd691b 100644 --- a/server/notification-providers/google-chat.js +++ b/server/notification-providers/google-chat.js @@ -2,6 +2,7 @@ const NotificationProvider = require("./notification-provider"); const axios = require("axios"); const { setting } = require("../util-server"); const { getMonitorRelativeURL } = require("../../src/util"); +const { UP } = require("../../src/util"); class GoogleChat extends NotificationProvider { From 8ad6bd31d40f67c58f542cfc8775765eed7cb47b Mon Sep 17 00:00:00 2001 From: Philipp Bischoff Date: Sun, 12 Dec 2021 00:08:33 +0100 Subject: [PATCH 04/15] Revert "order notification types by name" This reverts commit 83984668608fc9f3ff8e01f6c90fec4d8ecffff3. --- src/components/notifications/index.js | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index a7c967edf..678106102 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -32,33 +32,33 @@ import GoogleChat from './GoogleChat.vue'; * @type { Record } */ const NotificationFormList = { - "AliyunSMS": AliyunSMS, - "apprise": Apprise, - "Bark": Bark, - "clicksendsms": ClickSendSMS, - "DingDing": DingDing, - "discord": Discord, + "telegram": Telegram, + "webhook": Webhook, "smtp": STMP, - "Feishu": Feishu, - "Google Chat": GoogleChat, + "discord": Discord, + "teams": Teams, + "signal": Signal, "gotify": Gotify, - "line": Line, - "lunasea": LunaSea, - "matrix": Matrix, - "mattermost": Mattermost, - "octopush": Octopush, - "promosms": PromoSMS, - "pushbullet": Pushbullet, + "slack": Slack, + "rocket.chat": RocketChat, "pushover": Pushover, "pushy": Pushy, - "rocket.chat": RocketChat, + "octopush": Octopush, + "promosms": PromoSMS, + "clicksendsms": ClickSendSMS, + "lunasea": LunaSea, + "Feishu": Feishu, + "AliyunSMS": AliyunSMS, + "apprise": Apprise, + "pushbullet": Pushbullet, + "line": Line, + "mattermost": Mattermost, + "matrix": Matrix, + "DingDing": DingDing, + "Bark": Bark, "serwersms": SerwerSMS, - "signal": Signal, - "slack": Slack, "stackfield": Stackfield, - "teams": Teams, - "telegram": Telegram, - "webhook": Webhook + "Google Chat": GoogleChat } export default NotificationFormList From b10cecb362548cad285f60701544e9754e46e115 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 14 Dec 2021 17:59:26 +0100 Subject: [PATCH 05/15] Added sl-SI language Added sl-SI language --- src/components/settings/Security.vue | 6 + src/i18n.js | 1 + src/languages/sl-SI.js | 355 +++++++++++++++++++++++++++ 3 files changed, 362 insertions(+) create mode 100644 src/languages/sl-SI.js diff --git a/src/components/settings/Security.vue b/src/components/settings/Security.vue index 4ef6b3d9e..c94c39158 100644 --- a/src/components/settings/Security.vue +++ b/src/components/settings/Security.vue @@ -126,6 +126,12 @@

Bitte mit Vorsicht nutzen.

+ +