diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9afb8596e..3dc7c8b26 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,10 +4,10 @@ Fixes #(issue) ## Type of change -Please delete options that are not relevant. +Please delete any options that are not relevant. - Bug fix (non-breaking change which fixes an issue) -- User Interface +- User interface (UI) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Translation update @@ -18,7 +18,7 @@ Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I ran ESLint and other linters for modified files -- [ ] I have performed a self-review of my own code and test it +- [ ] I have performed a self-review of my own code and tested it - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] My changes generate no new warnings - [ ] My code needed automated testing. I have added them (this is optional task) diff --git a/extra/healthcheck.js b/extra/healthcheck.js index c6e8a349a..7c3a7eb42 100644 --- a/extra/healthcheck.js +++ b/extra/healthcheck.js @@ -20,7 +20,7 @@ if (sslKey && sslCert) { // Dual-stack support for (::) let hostname = process.env.UPTIME_KUMA_HOST; -// Also read HOST if not FreeBSD, as HOST is a system environment variable in FreeBSD +// Also read HOST if not *BSD, as HOST is a system environment variable in FreeBSD if (!hostname && !FBSD) { hostname = process.env.HOST; } diff --git a/package.json b/package.json index 32c51176d..d101ef5d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uptime-kuma", - "version": "1.11.1", + "version": "1.11.3", "license": "MIT", "repository": { "type": "git", @@ -27,16 +27,16 @@ "jest-backend": "cross-env TEST_BACKEND=1 jest --config=./config/jest-backend.config.js", "tsc": "tsc", "vite-preview-dist": "vite preview --host --config ./config/vite.config.js", - "build-docker": "npm run build-docker-debian && npm run build-docker-alpine", + "build-docker": "npm run build && npm run build-docker-debian && npm run build-docker-alpine", "build-docker-alpine-base": "docker buildx build -f docker/alpine-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-alpine . --push", "build-docker-debian-base": "docker buildx build -f docker/debian-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-debian . --push", - "build-docker-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:alpine -t louislam/uptime-kuma:1-alpine -t louislam/uptime-kuma:1.11.1-alpine --target release . --push", - "build-docker-debian": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.11.1 -t louislam/uptime-kuma:debian -t louislam/uptime-kuma:1-debian -t louislam/uptime-kuma:1.11.1-debian --target release . --push", - "build-docker-nightly": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly --target nightly . --push", + "build-docker-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:alpine -t louislam/uptime-kuma:1-alpine -t louislam/uptime-kuma:1.11.3-alpine --target release . --push", + "build-docker-debian": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.11.3 -t louislam/uptime-kuma:debian -t louislam/uptime-kuma:1-debian -t louislam/uptime-kuma:1.11.3-debian --target release . --push", + "build-docker-nightly": "npm run build && docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly --target nightly . --push", "build-docker-nightly-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly-alpine --target nightly . --push", "build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain", "upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain", - "setup": "git checkout 1.11.1 && npm ci --production && npm run download-dist", + "setup": "git checkout 1.11.3 && npm ci --production && npm run download-dist", "download-dist": "node extra/download-dist.js", "update-version": "node extra/update-version.js", "mark-as-nightly": "node extra/mark-as-nightly.js", diff --git a/server/notification-providers/google-chat.js b/server/notification-providers/google-chat.js index 1610553c7..6fb324288 100644 --- a/server/notification-providers/google-chat.js +++ b/server/notification-providers/google-chat.js @@ -6,7 +6,7 @@ const { DOWN, UP } = require("../../src/util"); class GoogleChat extends NotificationProvider { - name = "Google Chat"; + name = "GoogleChat"; async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; @@ -27,7 +27,7 @@ class GoogleChat extends NotificationProvider { textMsg += `${msg}`; const baseURL = await setting("primaryBaseURL"); - if (baseURL) { + if (baseURL && monitorJSON) { textMsg += `\n${baseURL + getMonitorRelativeURL(monitorJSON.id)}`; } diff --git a/server/notification-providers/smtp.js b/server/notification-providers/smtp.js index 1be68aeab..d85ee88c9 100644 --- a/server/notification-providers/smtp.js +++ b/server/notification-providers/smtp.js @@ -14,16 +14,20 @@ class SMTP extends NotificationProvider { secure: notification.smtpSecure, tls: { rejectUnauthorized: notification.smtpIgnoreTLSError || false, - }, - dkim: { + } + }; + + // Fix #1129 + if (notification.smtpDkimDomain) { + config.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 if (notification.smtpUsername || notification.smtpPassword) { 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 56a7e84d8..4d72c81c7 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 WeCom = require("./notification-providers/wecom"); const GoogleChat = require("./notification-providers/google-chat"); class Notification { @@ -63,6 +64,7 @@ class Notification { new Bark(), new SerwerSMS(), new Stackfield(), + new WeCom(), new GoogleChat() ]; diff --git a/server/ping-lite.js b/server/ping-lite.js index b2d6405ad..0075e80bd 100644 --- a/server/ping-lite.js +++ b/server/ping-lite.js @@ -48,7 +48,7 @@ function Ping(host, options) { this._args = (options.args) ? options.args : [ "-n", "-t", timeout, "-c", "1", host ]; this._regmatch = /=([0-9.]+?) ms/; - } else if (util.FBSD) { + } else if (util.BSD) { this._bin = "/sbin/ping"; const defaultArgs = [ "-n", "-t", timeout, "-c", "1", host ]; diff --git a/server/util-server.js b/server/util-server.js index 68f59f67f..2264ebea9 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -16,6 +16,7 @@ exports.WIN = /^win/.test(process.platform); exports.LIN = /^linux/.test(process.platform); exports.MAC = /^darwin/.test(process.platform); exports.FBSD = /^freebsd/.test(process.platform); +exports.BSD = /bsd$/.test(process.platform); /** * Init or reset JWT secret diff --git a/src/components/notifications/WeCom.vue b/src/components/notifications/WeCom.vue new file mode 100644 index 000000000..cef3708d1 --- /dev/null +++ b/src/components/notifications/WeCom.vue @@ -0,0 +1,12 @@ + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 9d870f91c..03945f90e 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -23,7 +23,8 @@ import AliyunSMS from "./AliyunSms.vue"; import DingDing from "./DingDing.vue"; import Bark from "./Bark.vue"; import SerwerSMS from "./SerwerSMS.vue"; -import Stackfield from "./Stackfield.vue"; +import Stackfield from './Stackfield.vue'; +import WeCom from "./WeCom.vue"; import GoogleChat from "./GoogleChat.vue"; /** @@ -58,7 +59,8 @@ const NotificationFormList = { "Bark": Bark, "serwersms": SerwerSMS, "stackfield": Stackfield, - "Google Chat (Google Workspace only)": GoogleChat + "WeCom": WeCom, + "GoogleChat": GoogleChat }; export default NotificationFormList; diff --git a/src/components/settings/Security.vue b/src/components/settings/Security.vue index c94c39158..94c6b5a67 100644 --- a/src/components/settings/Security.vue +++ b/src/components/settings/Security.vue @@ -175,9 +175,9 @@