Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam committed Jan 5, 2022
2 parents 4005856 + 2a1456c commit c5fe3a6
Show file tree
Hide file tree
Showing 19 changed files with 753 additions and 69 deletions.
2 changes: 1 addition & 1 deletion extra/close-incorrect-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const github = require("@actions/github");
owner: issue.owner,
repo: issue.repo,
issue_number: issue.number,
body: `@${username}: Hello! :wave:\n\nThis issue is being automatically closed because it does not follow the issue template. Please DO NOT open a blank issue`
body: `@${username}: Hello! :wave:\n\nThis issue is being automatically closed because it does not follow the issue template. Please DO NOT open a blank issue.`
});

// Close the issue
Expand Down
47 changes: 47 additions & 0 deletions server/notification-providers/google-chat.js
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;
8 changes: 8 additions & 0 deletions server/notification-providers/smtp.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ class SMTP extends NotificationProvider {
tls: {
rejectUnauthorized: notification.smtpIgnoreTLSError || false,
},
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
Expand Down
47 changes: 47 additions & 0 deletions server/notification-providers/wecom.js
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;
4 changes: 4 additions & 0 deletions server/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ 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 {

Expand Down Expand Up @@ -62,6 +64,8 @@ class Notification {
new Bark(),
new SerwerSMS(),
new Stackfield(),
new WeCom(),
new GoogleChat()
];

for (let item of list) {
Expand Down
14 changes: 14 additions & 0 deletions src/assets/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,20 @@ textarea.form-control {
opacity: 0;
}

.slide-fade-up-enter-active {
transition: all 0.2s $easing-in;
}

.slide-fade-up-leave-active {
transition: all 0.2s $easing-in;
}

.slide-fade-up-enter-from,
.slide-fade-up-leave-to {
transform: translateY(-50px);
opacity: 0;
}

.monitor-list {
&.scrollbar {
min-height: calc(100vh - 240px);
Expand Down
67 changes: 67 additions & 0 deletions src/components/ToggleSection.vue
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>
13 changes: 13 additions & 0 deletions src/components/notifications/GoogleChat.vue
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>
Loading

0 comments on commit c5fe3a6

Please sign in to comment.