From 063d64eec8d9aba488f4cd8f72f46ab327d06ed3 Mon Sep 17 00:00:00 2001 From: Willian Rodrigues Barbosa Date: Sun, 12 Sep 2021 14:46:59 -0300 Subject: [PATCH 01/10] feat: add microsoft teams notification provider --- server/notification-providers/teams.js | 118 +++++++++++++++++++++++++ server/notification.js | 2 + src/components/NotificationDialog.vue | 5 ++ src/components/notifications/Teams.vue | 29 ++++++ 4 files changed, 154 insertions(+) create mode 100644 server/notification-providers/teams.js create mode 100644 src/components/notifications/Teams.vue diff --git a/server/notification-providers/teams.js b/server/notification-providers/teams.js new file mode 100644 index 000000000..2cd5a36c5 --- /dev/null +++ b/server/notification-providers/teams.js @@ -0,0 +1,118 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const { DOWN, UP } = require("../../src/util"); + +class Teams extends NotificationProvider { + name = "teams"; + + _statusMessageFactory = (status, monitorName) => { + if (status === DOWN) { + return `🔴 Application [${monitorName}] went down`; + } else if (status === UP) { + return `✅ Application [${monitorName}] is back online`; + } + return "Notification test"; + }; + + _getThemeColor = (status) => { + if (status === DOWN) { + return "ff0000"; + } + if (status === UP) { + return "00e804"; + } + return "008cff"; + }; + + _notificationPayloadFactory = ({ + status, + monitorMessage, + monitorName, + monitorUrl, + }) => { + const notificationMessage = this._statusMessageFactory( + status, + monitorName + ); + return { + "@context": "https://schema.org/extensions", + "@type": "MessageCard", + themeColor: this._getThemeColor(status), + summary: notificationMessage, + sections: [ + { + activityImage: + "https://raw.githubusercontent.com/louislam/uptime-kuma/master/public/icon.png", + activityTitle: "**Uptime Kuma**", + }, + { + activityTitle: notificationMessage, + }, + { + activityTitle: "**Description**", + text: monitorMessage, + facts: [ + { + name: "Monitor", + value: monitorName, + }, + { + name: "URL", + value: monitorUrl, + }, + ], + }, + ], + }; + }; + + _sendNotification = async (webhookUrl, payload) => { + await axios.post(webhookUrl, payload); + }; + + _handleTestNotification = (webhookUrl) => { + const payload = this._notificationPayloadFactory({ + monitorMessage: "Just a test", + monitorName: "Test Notification", + monitorUrl: "http://localhost:3000", + }); + + return this._sendNotification(webhookUrl, payload); + }; + + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + let okMsg = "Sent Successfully. "; + + try { + if (heartbeatJSON == null) { + await this._handleTestNotification(notification.webhookUrl); + return okMsg; + } + + let url; + + if (monitorJSON["type"] === "port") { + url = monitorJSON["hostname"]; + if (monitorJSON["port"]) { + url += ":" + monitorJSON["port"]; + } + } else { + url = monitorJSON["url"]; + } + + const payload = this._notificationPayloadFactory({ + monitorMessage: heartbeatJSON.msg, + monitorName: monitorJSON.name, + monitorUrl: url, + status: heartbeatJSON.status, + }); + + await this._sendNotification(notification.webhookUrl, payload); + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Teams; diff --git a/server/notification.js b/server/notification.js index 83dabc537..134472410 100644 --- a/server/notification.js +++ b/server/notification.js @@ -13,6 +13,7 @@ const RocketChat = require("./notification-providers/rocket-chat"); const Signal = require("./notification-providers/signal"); const Slack = require("./notification-providers/slack"); const SMTP = require("./notification-providers/smtp"); +const Teams = require("./notification-providers/teams"); const Telegram = require("./notification-providers/telegram"); const Webhook = require("./notification-providers/webhook"); @@ -28,6 +29,7 @@ class Notification { const list = [ new Apprise(), new Discord(), + new Teams(), new Gotify(), new Line(), new LunaSea(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index ffb7ba71d..a83fa81c0 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -17,6 +17,7 @@ + @@ -395,6 +396,8 @@ + +
@@ -444,6 +447,7 @@ import { ucfirst } from "../util.ts" import Confirm from "./Confirm.vue"; import HiddenInput from "./HiddenInput.vue"; import Telegram from "./notifications/Telegram.vue"; +import Teams from "./notifications/Teams.vue"; import SMTP from "./notifications/SMTP.vue"; export default { @@ -451,6 +455,7 @@ export default { Confirm, HiddenInput, Telegram, + Teams, SMTP, }, props: {}, diff --git a/src/components/notifications/Teams.vue b/src/components/notifications/Teams.vue new file mode 100644 index 000000000..e28db2444 --- /dev/null +++ b/src/components/notifications/Teams.vue @@ -0,0 +1,29 @@ + + + From f351b423c56d294364f5fbf122f2a5bed954e6fe Mon Sep 17 00:00:00 2001 From: LouisLam Date: Mon, 13 Sep 2021 20:25:41 +0800 Subject: [PATCH 02/10] link to the english version of microsoft link --- src/components/notifications/Teams.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/notifications/Teams.vue b/src/components/notifications/Teams.vue index e28db2444..748bf7ad6 100644 --- a/src/components/notifications/Teams.vue +++ b/src/components/notifications/Teams.vue @@ -11,7 +11,7 @@
You can learn how to create a webhook url here.
From ccb8736b3d143f123e81acfce0a498f058e4d9ad Mon Sep 17 00:00:00 2001 From: Willian Rodrigues Barbosa Date: Mon, 13 Sep 2021 14:02:52 -0300 Subject: [PATCH 03/10] fix: send msg if heartbeat message is not set --- server/notification-providers/teams.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notification-providers/teams.js b/server/notification-providers/teams.js index 2cd5a36c5..6021883ee 100644 --- a/server/notification-providers/teams.js +++ b/server/notification-providers/teams.js @@ -101,7 +101,7 @@ class Teams extends NotificationProvider { } const payload = this._notificationPayloadFactory({ - monitorMessage: heartbeatJSON.msg, + monitorMessage: heartbeatJSON.msg || msg, monitorName: monitorJSON.name, monitorUrl: url, status: heartbeatJSON.status, From fff5fd8e9e7be4d3d571bcac3c0dfd7858deae61 Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Tue, 14 Sep 2021 17:48:29 +0200 Subject: [PATCH 04/10] Added search key --- src/languages/de-DE.js | 1 + src/languages/en.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/languages/de-DE.js b/src/languages/de-DE.js index fcae94155..243c2157d 100644 --- a/src/languages/de-DE.js +++ b/src/languages/de-DE.js @@ -157,4 +157,5 @@ export default { Indigo: "Indigo", Purple: "Lila", Pink: "Pink", + "Search...": "Suchen...", } diff --git a/src/languages/en.js b/src/languages/en.js index 4f88d3046..a378ddcb3 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -157,4 +157,5 @@ export default { Indigo: "Indigo", Purple: "Purple", Pink: "Pink", + "Search...": "Search...", } From 3425a27a0e4867d737fa051ac1efa88fbfb23e3b Mon Sep 17 00:00:00 2001 From: Ziding Zhang Date: Tue, 14 Sep 2021 17:54:51 +0100 Subject: [PATCH 05/10] Update SECURITY.md I'd like to report a security issue and felt it most prudent not to disclose it publicly, as per your Security policy instructions. If not a hassle, might you kindly add an email, or other private contact method? GitHub [recommends](https://docs.github.com/en/code-security/getting-started/adding-a-security-policy-to-your-repository) this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future. Thank you for your consideration! --- SECURITY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SECURITY.md b/SECURITY.md index 47f0786f9..de596bb89 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -10,5 +10,6 @@ currently being supported with security updates. | 1.x.x | :white_check_mark: | ## Reporting a Vulnerability +Please report security issues to https://github.com/louislam/uptime-kuma/issues From 0b32adadb89a42241a172cbbe8e71c7bd7d9535f Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Wed, 15 Sep 2021 01:12:59 +0800 Subject: [PATCH 06/10] Update SECURITY.md --- SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SECURITY.md b/SECURITY.md index de596bb89..a83245d63 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -10,6 +10,6 @@ currently being supported with security updates. | 1.x.x | :white_check_mark: | ## Reporting a Vulnerability -Please report security issues to +Please report security issues to uptime@kuma.pet https://github.com/louislam/uptime-kuma/issues From 76348cae5d7809476d9113040b438179dbbe6fc7 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Wed, 15 Sep 2021 01:17:33 +0800 Subject: [PATCH 07/10] Update SECURITY.md --- SECURITY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index a83245d63..1271565a2 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -10,6 +10,6 @@ currently being supported with security updates. | 1.x.x | :white_check_mark: | ## Reporting a Vulnerability -Please report security issues to uptime@kuma.pet +Please report security issues to uptime@kuma.pet. -https://github.com/louislam/uptime-kuma/issues +Do not use the issue tracker or discuss it in the public as it will cause more damage. From 7274913686022ed421cd76f8a205a7dedb4ae027 Mon Sep 17 00:00:00 2001 From: "samet.kum" Date: Wed, 15 Sep 2021 02:55:04 +0300 Subject: [PATCH 08/10] Turkish Language added --- src/i18n.js | 2 + src/languages/tr-TR.js | 120 +++++++++++++++++++++++++++++++++++++++++ src/pages/Settings.vue | 6 +++ 3 files changed, 128 insertions(+) create mode 100644 src/languages/tr-TR.js diff --git a/src/i18n.js b/src/i18n.js index 0640a1ae5..fe2612fbc 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -13,6 +13,7 @@ import pl from "./languages/pl"; import ruRU from "./languages/ru-RU"; import sr from "./languages/sr"; import srLatn from "./languages/sr-latn"; +import trTR from "./languages/tr-TR"; import svSE from "./languages/sv-SE"; import zhCN from "./languages/zh-CN"; import zhHK from "./languages/zh-HK"; @@ -30,6 +31,7 @@ const languageList = { "sr": sr, "sr-latn": srLatn, "sv-SE": svSE, + "tr-TR": trTR, "ko-KR": koKR, "ru-RU": ruRU, "zh-CN": zhCN, diff --git a/src/languages/tr-TR.js b/src/languages/tr-TR.js new file mode 100644 index 000000000..e05af23e3 --- /dev/null +++ b/src/languages/tr-TR.js @@ -0,0 +1,120 @@ +export default { + languageName: "Türkçe", + checkEverySecond: "{0} Saniyede bir kontrol et.", + "Avg.": "Ortalama", + retriesDescription: "Servisin kapalı olarak işaretlenmeden ve bir bildirim gönderilmeden önce maksimum yeniden deneme sayısı", + ignoreTLSError: "HTTPS web siteleri için TLS/SSL hatasını yoksay", + upsideDownModeDescription: "Servisin durumunu tersine çevirir. Servis çalışıyorsa kapalı olarak işaretler.", + maxRedirectDescription: "İzlenecek maksimum yönlendirme sayısı. Yönlendirmeleri devre dışı bırakmak için 0'a ayarlayın.", + acceptedStatusCodesDescription: "Servisin çalıştığını hangi durum kodları belirlesin?", + passwordNotMatchMsg: "Şifre eşleşmiyor.", + notificationDescription: "Servislerin bildirim gönderebilmesi için bir bildirim yöntemi belirleyin.", + keywordDescription: "Anahtar kelimeyi düz html veya JSON yanıtında arayın ve büyük/küçük harfe duyarlıdır", + pauseDashboardHome: "Durdur", + deleteMonitorMsg: "Servisi silmek istediğinden emin misin?", + deleteNotificationMsg: "Bu bildirimi tüm servisler için silmek istediğinden emin misin?", + resoverserverDescription: "Cloudflare varsayılan sunucudur, çözümleyici sunucusunu istediğiniz zaman değiştirebilirsiniz.", + rrtypeDescription: "İzlemek istediğiniz servisin RR-Tipini seçin", + pauseMonitorMsg: "Durdurmak istediğinden emin misin?", + clearEventsMsg: "Bu servisin bütün kayıtlarını silmek istediğinden emin misin?", + clearHeartbeatsMsg: "Bu servis için tüm sağlık durumunu silmek istediğinden emin misin?", + confirmClearStatisticsMsg: "Tüm istatistikleri silmek istediğinden emin misin?", + Settings: "Ayarlar", + Dashboard: "Panel", + "New Update": "Yeni Güncelleme", + Language: "Dil", + Appearance: "Görünüm", + Theme: "Tema", + General: "Genel", + Version: "Versiyon", + "Check Update On GitHub": "GitHub'da Güncellemeyi Kontrol Edin", + List: "Liste", + Add: "Ekle", + "Add New Monitor": "Yeni Servis Ekle", + "Quick Stats": "Servis istatistikleri", + Up: "Normal", + Down: "Hatalı", + Pending: "Bekliyor", + Unknown: "Bilinmeyen", + Pause: "Durdur", + Name: "Servis ismi", + Status: "Durum", + DateTime: "Zaman", + Message: "Mesaj", + "No important events": "Önemli olay yok", + Resume: "Devam et", + Edit: "Düzenle", + Delete: "Sil", + Current: "Şu anda", + Uptime: "Çalışma zamanı", + "Cert Exp.": "Sertifika Süresi", + days: "günler", + day: "gün", + "-day": "-gün", + hour: "saat", + "-hour": "-saat", + Response: "Cevap Süresi", + Ping: "Ping", + "Monitor Type": "Servis Tipi", + Keyword: "Anahtar Kelime", + "Friendly Name": "Panelde görünecek isim", + URL: "URL", + Hostname: "IP Adresi", + Port: "Port", + "Heartbeat Interval": "Servis Test Aralığı", + Retries: "Yeniden deneme", + Advanced: "Gelişmiş", + "Upside Down Mode": "Ters/Düz Modu", + "Max. Redirects": "Maksimum Yönlendirme", + "Accepted Status Codes": "Kabul Edilen Durum Kodları", + Save: "Kaydet", + Notifications: "Bildirimler", + "Not available, please setup.": "Atanmış bildirim yöntemi yok. Ayarlardan belirleyebilirsiniz.", + "Setup Notification": "Bildirim yöntemi kur", + Light: "Açık", + Dark: "Koyu", + Auto: "Oto", + "Theme - Heartbeat Bar": "Servis Bar Konumu", + Normal: "Normal", + Bottom: "Aşağıda", + None: "Gösterme", + Timezone: "Zaman Dilimi", + "Search Engine Visibility": "Arama Motoru Görünürlüğü", + "Allow indexing": "İndekslemeye izin ver", + "Discourage search engines from indexing site": "İndekslemeyi reddet", + "Change Password": "Şifre Değiştir", + "Current Password": "Şuan ki Şifre", + "New Password": "Yeni Şifre", + "Repeat New Password": "Yeni Şifreyi Tekrar Girin", + "Update Password": "Şifreyi Değiştir", + "Disable Auth": "Şifreli girişi iptal et.", + "Enable Auth": "Şifreli girişi aktif et.", + Logout: "Çıkış yap", + Leave: "Ayrıl", + "I understand, please disable": "Evet farkındayım, iptal et", + Confirm: "Onayla", + Yes: "Evet", + No: "Hayır", + Username: "Kullanıcı Adı", + Password: "Şifre", + "Remember me": "Beni Hatırla", + Login: "Giriş yap", + "No Monitors, please": "Servis yok, lütfen", + "add one": "bir servis ekleyin", + "Notification Type": "Bildirim Yöntemi", + Email: "E-mail", + Test: "Test", + "Certificate Info": "Sertifika Bilgisi", + "Resolver Server": "Çözümleyici Sunucu", + "Resource Record Type": "Kaynak Kayıt Türü", + "Last Result": "En son sonuçlar", + "Create your admin account": "Yönetici hesabınızı oluşturun", + "Repeat Password": "Şifrenizi tekrar girin", + respTime: "Cevap Süresi (ms)", + notAvailableShort: "N/A", + Create: "Yarat", + "Clear Data": "Verileri Temizle", + Events: "Olaylar", + Heartbeats: "Sağlık Durumları", + "Auto Get": "Otomatik Al" +} diff --git a/src/pages/Settings.vue b/src/pages/Settings.vue index 03fd89f51..0e809f736 100644 --- a/src/pages/Settings.vue +++ b/src/pages/Settings.vue @@ -232,6 +232,12 @@

Molim Vas koristite ovo sa pažnjom.

+ +