mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-30 18:24:03 +00:00
Merge branch 'louislam:master' into master
This commit is contained in:
commit
0e50b71290
5 changed files with 78 additions and 5 deletions
47
server/notification-providers/google-chat.js
Normal file
47
server/notification-providers/google-chat.js
Normal file
|
@ -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;
|
|
@ -25,6 +25,7 @@ const DingDing = require("./notification-providers/dingding");
|
||||||
const Bark = require("./notification-providers/bark");
|
const Bark = require("./notification-providers/bark");
|
||||||
const SerwerSMS = require("./notification-providers/serwersms");
|
const SerwerSMS = require("./notification-providers/serwersms");
|
||||||
const Stackfield = require("./notification-providers/stackfield");
|
const Stackfield = require("./notification-providers/stackfield");
|
||||||
|
const GoogleChat = require("./notification-providers/google-chat");
|
||||||
|
|
||||||
class Notification {
|
class Notification {
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ class Notification {
|
||||||
new Bark(),
|
new Bark(),
|
||||||
new SerwerSMS(),
|
new SerwerSMS(),
|
||||||
new Stackfield(),
|
new Stackfield(),
|
||||||
|
new GoogleChat()
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let item of list) {
|
for (let item of list) {
|
||||||
|
|
13
src/components/notifications/GoogleChat.vue
Normal file
13
src/components/notifications/GoogleChat.vue
Normal file
|
@ -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>
|
|
@ -1,4 +1,4 @@
|
||||||
import STMP from "./SMTP.vue"
|
import STMP from "./SMTP.vue";
|
||||||
import Telegram from "./Telegram.vue";
|
import Telegram from "./Telegram.vue";
|
||||||
import Discord from "./Discord.vue";
|
import Discord from "./Discord.vue";
|
||||||
import Webhook from "./Webhook.vue";
|
import Webhook from "./Webhook.vue";
|
||||||
|
@ -23,7 +23,8 @@ import AliyunSMS from "./AliyunSms.vue";
|
||||||
import DingDing from "./DingDing.vue";
|
import DingDing from "./DingDing.vue";
|
||||||
import Bark from "./Bark.vue";
|
import Bark from "./Bark.vue";
|
||||||
import SerwerSMS from "./SerwerSMS.vue";
|
import SerwerSMS from "./SerwerSMS.vue";
|
||||||
import Stackfield from './Stackfield.vue';
|
import Stackfield from "./Stackfield.vue";
|
||||||
|
import GoogleChat from "./GoogleChat.vue";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage all notification form.
|
* Manage all notification form.
|
||||||
|
@ -57,6 +58,7 @@ const NotificationFormList = {
|
||||||
"Bark": Bark,
|
"Bark": Bark,
|
||||||
"serwersms": SerwerSMS,
|
"serwersms": SerwerSMS,
|
||||||
"stackfield": Stackfield,
|
"stackfield": Stackfield,
|
||||||
}
|
"Google Chat (Google Workspace only)": GoogleChat
|
||||||
|
};
|
||||||
|
|
||||||
export default NotificationFormList
|
export default NotificationFormList;
|
||||||
|
|
|
@ -351,4 +351,13 @@ export default {
|
||||||
serwersmsPhoneNumber: "Телефон номер",
|
serwersmsPhoneNumber: "Телефон номер",
|
||||||
serwersmsSenderName: "SMS Подател име (регистриран през клиентския портал)",
|
serwersmsSenderName: "SMS Подател име (регистриран през клиентския портал)",
|
||||||
stackfield: "Stackfield",
|
stackfield: "Stackfield",
|
||||||
|
smtpDkimSettings: "DKIM Настройки",
|
||||||
|
smtpDkimDesc: "Моля, вижте Nodemailer DKIM {0} за инструкции.",
|
||||||
|
documentation: "документация",
|
||||||
|
smtpDkimDomain: "Домейн",
|
||||||
|
smtpDkimKeySelector: "Селектор на ключ",
|
||||||
|
smtpDkimPrivateKey: "Частен ключ",
|
||||||
|
smtpDkimHashAlgo: "Хеш алгоритъм (по желание)",
|
||||||
|
smtpDkimheaderFieldNames: "Хедър ключове за подписване (по желание)",
|
||||||
|
smtpDkimskipFields: "Хедър ключове, които да не се подписеат (по желание)",
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue