diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e9829c96f..12fd6ed41 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,7 @@ The frontend code build into "dist" directory. The server (express.js) exposes t ## Can I create a pull request for Uptime Kuma? -Yes or no, it depends on what you will try to do. Since I don't want to waste your time, be sure to **create empty draft pull request or open an issue, so we can discuss first**. Especially for a large pull request or you don't know it will be merged or not. +Yes or no, it depends on what you will try to do. Since I don't want to waste your time, be sure to **create an empty draft pull request or open an issue, so we can discuss first**. Especially for a large pull request or you don't know it will be merged or not. Here are some references: @@ -48,7 +48,7 @@ Here are some references: - UI/UX is not close to Uptime Kuma - Existing logic is completely modified or deleted for no reason - A function that is completely out of scope -- Unnesscary large code changes (Hard to review, casuse code conflicts to other pull requests) +- Unnecessary large code changes (Hard to review, causes code conflicts to other pull requests) I will mark your pull request in the [milestones](https://github.com/louislam/uptime-kuma/milestones), if I am plan to review and merge it. @@ -183,7 +183,7 @@ By default, the Chromium window will be shown up during the test. Specifying `HE ## Dependencies -Both frontend and backend share the same package.json. However, the frontend dependencies are eventually not be used in production environment, because it is usually also baked into dist files. So: +Both frontend and backend share the same package.json. However, the frontend dependencies are eventually not used in the production environment, because it is usually also baked into dist files. So: - Frontend dependencies = "devDependencies" - Examples: vue, chart.js diff --git a/server/notification-providers/ntfy.js b/server/notification-providers/ntfy.js index 21f358f64..17d6d812a 100644 --- a/server/notification-providers/ntfy.js +++ b/server/notification-providers/ntfy.js @@ -8,12 +8,19 @@ class Ntfy extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; try { - await axios.post(`${notification.ntfyserverurl}`, { + let headers = {}; + if (notification.ntfyusername.length > 0) { + headers = { + "Authorization": "Basic " + Buffer.from(notification.ntfyusername + ":" + notification.ntfypassword).toString("base64"), + }; + } + let data = { "topic": notification.ntfytopic, "message": msg, "priority": notification.ntfyPriority || 4, "title": "Uptime-Kuma", - }); + }; + await axios.post(`${notification.ntfyserverurl}`, data, { headers: headers }); return okMsg; diff --git a/server/notification-providers/octopush.js b/server/notification-providers/octopush.js index 0eda940ba..d5c475d3d 100644 --- a/server/notification-providers/octopush.js +++ b/server/notification-providers/octopush.js @@ -10,7 +10,7 @@ class Octopush extends NotificationProvider { try { // Default - V2 - if (notification.octopushVersion === 2 || !notification.octopushVersion) { + if (notification.octopushVersion === "2" || !notification.octopushVersion) { let config = { headers: { "api-key": notification.octopushAPIKey, @@ -31,7 +31,7 @@ class Octopush extends NotificationProvider { "sender": notification.octopushSenderName }; await axios.post("https://api.octopush.com/v1/public/sms-campaign/send", data, config); - } else if (notification.octopushVersion === 1) { + } else if (notification.octopushVersion === "1") { let data = { "user_login": notification.octopushDMLogin, "api_key": notification.octopushDMAPIKey, @@ -49,7 +49,15 @@ class Octopush extends NotificationProvider { }, params: data }; - await axios.post("https://www.octopush-dm.com/api/sms/json", {}, config); + + // V1 API returns 200 even on error so we must check + // response data + let response = await axios.post("https://www.octopush-dm.com/api/sms/json", {}, config); + if ("error_code" in response.data) { + if (response.data.error_code !== "000") { + this.throwGeneralAxiosError(`Octopush error ${JSON.stringify(response.data)}`); + } + } } else { throw new Error("Unknown Octopush version!"); } diff --git a/server/notification-providers/teams.js b/server/notification-providers/teams.js index c398e03c2..bcfc82c24 100644 --- a/server/notification-providers/teams.js +++ b/server/notification-providers/teams.js @@ -63,7 +63,7 @@ class Teams extends NotificationProvider { }); } - if (monitorUrl) { + if (monitorUrl && monitorUrl !== "https://") { facts.push({ name: "URL", value: monitorUrl, @@ -127,13 +127,17 @@ class Teams extends NotificationProvider { let url; - if (monitorJSON["type"] === "port") { - url = monitorJSON["hostname"]; - if (monitorJSON["port"]) { - url += ":" + monitorJSON["port"]; - } - } else { - url = monitorJSON["url"]; + switch (monitorJSON["type"]) { + case "http": + case "keywork": + url = monitorJSON["url"]; + break; + case "docker": + url = monitorJSON["docker_host"]; + break; + default: + url = monitorJSON["hostname"]; + break; } const payload = this._notificationPayloadFactory({ diff --git a/src/components/notifications/Ntfy.vue b/src/components/notifications/Ntfy.vue index d9a83b499..ddcc39174 100644 --- a/src/components/notifications/Ntfy.vue +++ b/src/components/notifications/Ntfy.vue @@ -11,15 +11,31 @@ -