11 changed files with 322 additions and 17 deletions
			
			
		@ -0,0 +1,124 @@ | 
				
			|||
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"; | 
				
			|||
    }; | 
				
			|||
 | 
				
			|||
    _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 | 
				
			|||
        ); | 
				
			|||
 | 
				
			|||
        const facts = []; | 
				
			|||
 | 
				
			|||
        if (monitorName) { | 
				
			|||
            facts.push({ | 
				
			|||
                name: "Monitor", | 
				
			|||
                value: monitorName, | 
				
			|||
            }); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        if (monitorUrl) { | 
				
			|||
            facts.push({ | 
				
			|||
                name: "URL", | 
				
			|||
                value: monitorUrl, | 
				
			|||
            }); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        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, | 
				
			|||
                }, | 
				
			|||
            ], | 
				
			|||
        }; | 
				
			|||
    }; | 
				
			|||
 | 
				
			|||
    _sendNotification = async (webhookUrl, payload) => { | 
				
			|||
        await axios.post(webhookUrl, payload); | 
				
			|||
    }; | 
				
			|||
 | 
				
			|||
    _handleGeneralNotification = (webhookUrl, msg) => { | 
				
			|||
        const payload = this._notificationPayloadFactory({ | 
				
			|||
            monitorMessage: msg | 
				
			|||
        }); | 
				
			|||
 | 
				
			|||
        return this._sendNotification(webhookUrl, payload); | 
				
			|||
    }; | 
				
			|||
 | 
				
			|||
    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { | 
				
			|||
        let okMsg = "Sent Successfully. "; | 
				
			|||
 | 
				
			|||
        try { | 
				
			|||
            if (heartbeatJSON == null) { | 
				
			|||
                await this._handleGeneralNotification(notification.webhookUrl, msg); | 
				
			|||
                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; | 
				
			|||
@ -0,0 +1,29 @@ | 
				
			|||
<template> | 
				
			|||
    <div class="mb-3"> | 
				
			|||
        <label for="teams-webhookurl" class="form-label">Webhook URL</label> | 
				
			|||
        <input | 
				
			|||
            id="teams-webhookurl" | 
				
			|||
            v-model="$parent.notification.webhookUrl" | 
				
			|||
            type="text" | 
				
			|||
            class="form-control" | 
				
			|||
            required | 
				
			|||
        /> | 
				
			|||
        <div class="form-text"> | 
				
			|||
            You can learn how to create a webhook url | 
				
			|||
            <a | 
				
			|||
                href="https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook" | 
				
			|||
                target="_blank" | 
				
			|||
            >here</a>. | 
				
			|||
        </div> | 
				
			|||
    </div> | 
				
			|||
</template> | 
				
			|||
 | 
				
			|||
<script> | 
				
			|||
export default { | 
				
			|||
    data() { | 
				
			|||
        return { | 
				
			|||
            name: "teams", | 
				
			|||
        }; | 
				
			|||
    }, | 
				
			|||
}; | 
				
			|||
</script> | 
				
			|||
@ -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" | 
				
			|||
} | 
				
			|||
					Loading…
					
					
				
		Reference in new issue