diff --git a/extra/close-incorrect-issue.js b/extra/close-incorrect-issue.js index be4ed8083..a15a5da37 100644 --- a/extra/close-incorrect-issue.js +++ b/extra/close-incorrect-issue.js @@ -37,7 +37,7 @@ const github = require("@actions/github"); owner: issue.owner, repo: issue.repo, issue_number: issue.number, - body: `@${username}: Hello! :wave:\n\nThis issue is being automatically closed because it does not follow the issue template. Please DO NOT open a blank issue` + body: `@${username}: Hello! :wave:\n\nThis issue is being automatically closed because it does not follow the issue template. Please DO NOT open a blank issue.` }); // Close the issue diff --git a/server/notification-providers/google-chat.js b/server/notification-providers/google-chat.js new file mode 100644 index 000000000..1610553c7 --- /dev/null +++ b/server/notification-providers/google-chat.js @@ -0,0 +1,47 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const { setting } = require("../util-server"); +const { getMonitorRelativeURL } = require("../../src/util"); +const { DOWN, UP } = 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\n`; + } else if (heartbeatJSON && heartbeatJSON.status === DOWN) { + textMsg = `🔴 Application went down\n`; + } + + if (monitorJSON && monitorJSON.name) { + textMsg += `*${monitorJSON.name}*\n`; + } + + textMsg += `${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-providers/smtp.js b/server/notification-providers/smtp.js index 14429bcab..1be68aeab 100644 --- a/server/notification-providers/smtp.js +++ b/server/notification-providers/smtp.js @@ -15,6 +15,14 @@ class SMTP extends NotificationProvider { tls: { rejectUnauthorized: notification.smtpIgnoreTLSError || false, }, + dkim: { + domainName: notification.smtpDkimDomain, + keySelector: notification.smtpDkimKeySelector, + privateKey: notification.smtpDkimPrivateKey, + hashAlgo: notification.smtpDkimHashAlgo, + headerFieldNames: notification.smtpDkimheaderFieldNames, + skipFields: notification.smtpDkimskipFields, + } }; // Should fix the issue in https://github.com/louislam/uptime-kuma/issues/26#issuecomment-896373904 diff --git a/server/notification-providers/wecom.js b/server/notification-providers/wecom.js new file mode 100644 index 000000000..7ba8c3783 --- /dev/null +++ b/server/notification-providers/wecom.js @@ -0,0 +1,47 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const { DOWN, UP } = require("../../src/util"); + +class WeCom extends NotificationProvider { + + name = "WeCom"; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully."; + + try { + let WeComUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=" + notification.weComBotKey; + let config = { + headers: { + "Content-Type": "application/json" + } + }; + let body = this.composeMessage(heartbeatJSON, msg); + await axios.post(WeComUrl, body, config); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } + + composeMessage(heartbeatJSON, msg) { + let title; + if (msg != null && heartbeatJSON != null && heartbeatJSON['status'] == UP) { + title = "UptimeKuma Monitor Up"; + } + if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] == DOWN) { + title = "UptimeKuma Monitor Down"; + } + if (msg != null) { + title = "UptimeKuma Message"; + } + return { + msgtype: "text", + text: { + content: title + msg + } + }; + } +} + +module.exports = WeCom; diff --git a/server/notification.js b/server/notification.js index 3eb5f97bf..4d72c81c7 100644 --- a/server/notification.js +++ b/server/notification.js @@ -25,6 +25,8 @@ 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 WeCom = require("./notification-providers/wecom"); +const GoogleChat = require("./notification-providers/google-chat"); class Notification { @@ -62,6 +64,8 @@ class Notification { new Bark(), new SerwerSMS(), new Stackfield(), + new WeCom(), + new GoogleChat() ]; for (let item of list) { diff --git a/src/assets/app.scss b/src/assets/app.scss index 5578946bd..cec644676 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -313,6 +313,20 @@ textarea.form-control { opacity: 0; } +.slide-fade-up-enter-active { + transition: all 0.2s $easing-in; +} + +.slide-fade-up-leave-active { + transition: all 0.2s $easing-in; +} + +.slide-fade-up-enter-from, +.slide-fade-up-leave-to { + transform: translateY(-50px); + opacity: 0; +} + .monitor-list { &.scrollbar { min-height: calc(100vh - 240px); diff --git a/src/components/ToggleSection.vue b/src/components/ToggleSection.vue new file mode 100644 index 000000000..bc6028d70 --- /dev/null +++ b/src/components/ToggleSection.vue @@ -0,0 +1,67 @@ + + + + + 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/SMTP.vue b/src/components/notifications/SMTP.vue index ab660abed..899f8f9bd 100644 --- a/src/components/notifications/SMTP.vue +++ b/src/components/notifications/SMTP.vue @@ -1,82 +1,117 @@