-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
19 changed files
with
753 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<template> | ||
<div class="my-3 py-3"> | ||
<h5 @click="isOpen = !isOpen"> | ||
<div | ||
class=" | ||
w-50 | ||
d-flex | ||
justify-content-between | ||
align-items-center | ||
pe-2 | ||
" | ||
> | ||
<span class="pb-2">{{ heading }}</span> | ||
<font-awesome-icon | ||
icon="chevron-down" | ||
class="animated" | ||
:class="{ open: isOpen }" | ||
/> | ||
</div> | ||
</h5> | ||
<transition name="slide-fade-up"> | ||
<div v-if="isOpen" class="mt-3"> | ||
<slot></slot> | ||
</div> | ||
</transition> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
heading: { | ||
type: String, | ||
default: "", | ||
}, | ||
defaultOpen: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
isOpen: this.defaultOpen, | ||
}; | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import "../assets/vars.scss"; | ||
h5:after { | ||
content: ""; | ||
display: block; | ||
width: 50%; | ||
padding-top: 8px; | ||
border-bottom: 1px solid $dark-border-color; | ||
} | ||
.open { | ||
transform: rotate(180deg); | ||
} | ||
.animated { | ||
transition: all 0.2s $easing-in; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<template> | ||
<div class="mb-3"> | ||
<label for="google-chat-webhook-url" class="form-label">{{ $t("Webhook URL") }}<span style="color: red;"><sup>*</sup></span></label> | ||
<input id="google-chat-webhook-url" v-model="$parent.notification.googleChatWebhookURL" type="text" class="form-control" required> | ||
|
||
<div class="form-text"> | ||
<span style="color: red;"><sup>*</sup></span>{{ $t("Required") }} | ||
<i18n-t tag="p" keypath="aboutWebhooks" style="margin-top: 8px;"> | ||
<a href="https://developers.google.com/chat/how-tos/webhooks" target="_blank">https://developers.google.com/chat/how-tos/webhooks</a> | ||
</i18n-t> | ||
</div> | ||
</div> | ||
</template> |
Oops, something went wrong.