mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 14:54:05 +00:00
Merge branch 'master' into hide-uptime-percentage
This commit is contained in:
commit
75f2c69ac5
4 changed files with 78 additions and 30 deletions
14
.github/workflows/auto-test.yml
vendored
14
.github/workflows/auto-test.yml
vendored
|
@ -22,7 +22,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, ubuntu-latest, windows-latest, ARM64]
|
os: [macos-latest, ubuntu-latest, windows-latest, ARM64]
|
||||||
node: [ 14, 20.5 ]
|
node: [ 16, 20.5 ]
|
||||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
@ -33,10 +33,13 @@ jobs:
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
- run: npm install npm@9 -g
|
|
||||||
- run: npm install
|
- name: Install
|
||||||
- run: npm run build
|
run: npm install
|
||||||
- run: npm run test-backend
|
- name: Build
|
||||||
|
run: npm run build
|
||||||
|
- name: Test Backend
|
||||||
|
run: npm run test-backend
|
||||||
env:
|
env:
|
||||||
HEADLESS_TEST: 1
|
HEADLESS_TEST: 1
|
||||||
JUST_FOR_TEST: ${{ secrets.JUST_FOR_TEST }}
|
JUST_FOR_TEST: ${{ secrets.JUST_FOR_TEST }}
|
||||||
|
@ -61,7 +64,6 @@ jobs:
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
- run: npm install npm@9 -g
|
|
||||||
- run: npm ci --production
|
- run: npm ci --production
|
||||||
|
|
||||||
check-linters:
|
check-linters:
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
const NotificationProvider = require("./notification-provider");
|
const NotificationProvider = require("./notification-provider");
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const { setting } = require("../util-server");
|
const { setting } = require("../util-server");
|
||||||
const { getMonitorRelativeURL } = require("../../src/util");
|
const { getMonitorRelativeURL, UP } = require("../../src/util");
|
||||||
const { DOWN, UP } = require("../../src/util");
|
|
||||||
|
|
||||||
class GoogleChat extends NotificationProvider {
|
class GoogleChat extends NotificationProvider {
|
||||||
name = "GoogleChat";
|
name = "GoogleChat";
|
||||||
|
@ -16,26 +15,71 @@ class GoogleChat extends NotificationProvider {
|
||||||
try {
|
try {
|
||||||
// Google Chat message formatting: https://developers.google.com/chat/api/guides/message-formats/basic
|
// Google Chat message formatting: https://developers.google.com/chat/api/guides/message-formats/basic
|
||||||
|
|
||||||
let textMsg = "";
|
let chatHeader = {
|
||||||
if (heartbeatJSON && heartbeatJSON.status === UP) {
|
title: "Uptime Kuma Alert",
|
||||||
textMsg = "✅ Application is back online\n";
|
};
|
||||||
} else if (heartbeatJSON && heartbeatJSON.status === DOWN) {
|
|
||||||
textMsg = "🔴 Application went down\n";
|
if (monitorJSON && heartbeatJSON) {
|
||||||
|
chatHeader["title"] =
|
||||||
|
heartbeatJSON["status"] === UP
|
||||||
|
? `✅ ${monitorJSON["name"]} is back online`
|
||||||
|
: `🔴 ${monitorJSON["name"]} went down`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitorJSON && monitorJSON.name) {
|
// always show msg
|
||||||
textMsg += `*${monitorJSON.name}*\n`;
|
let sectionWidgets = [
|
||||||
|
{
|
||||||
|
textParagraph: {
|
||||||
|
text: `<b>Message:</b>\n${msg}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// add time if available
|
||||||
|
if (heartbeatJSON) {
|
||||||
|
sectionWidgets.push({
|
||||||
|
textParagraph: {
|
||||||
|
text: `<b>Time (${heartbeatJSON["timezone"]}):</b>\n${heartbeatJSON["localDateTime"]}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
textMsg += `${msg}`;
|
// add button for monitor link if available
|
||||||
|
|
||||||
const baseURL = await setting("primaryBaseURL");
|
const baseURL = await setting("primaryBaseURL");
|
||||||
if (baseURL && monitorJSON) {
|
if (baseURL) {
|
||||||
textMsg += `\n${baseURL + getMonitorRelativeURL(monitorJSON.id)}`;
|
const urlPath = monitorJSON ? getMonitorRelativeURL(monitorJSON.id) : "/";
|
||||||
|
sectionWidgets.push({
|
||||||
|
buttonList: {
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: "Visit Uptime Kuma",
|
||||||
|
onClick: {
|
||||||
|
openLink: {
|
||||||
|
url: baseURL + urlPath,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {
|
let chatSections = [
|
||||||
"text": textMsg,
|
{
|
||||||
|
widgets: sectionWidgets,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// construct json data
|
||||||
|
let data = {
|
||||||
|
cardsV2: [
|
||||||
|
{
|
||||||
|
card: {
|
||||||
|
header: chatHeader,
|
||||||
|
sections: chatSections,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
await axios.post(notification.googleChatWebhookURL, data);
|
await axios.post(notification.googleChatWebhookURL, data);
|
||||||
|
|
|
@ -23,6 +23,8 @@ class HomeAssistant extends NotificationProvider {
|
||||||
...(notificationService !== "persistent_notification" && { data: {
|
...(notificationService !== "persistent_notification" && { data: {
|
||||||
name: monitorJSON?.name,
|
name: monitorJSON?.name,
|
||||||
status: heartbeatJSON?.status,
|
status: heartbeatJSON?.status,
|
||||||
|
channel: "Uptime Kuma",
|
||||||
|
icon_url: "https://github.com/louislam/uptime-kuma/blob/master/public/icon.png?raw=true",
|
||||||
} }),
|
} }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1619,15 +1619,15 @@ async function afterLogin(socket, user) {
|
||||||
socket.join(user.id);
|
socket.join(user.id);
|
||||||
|
|
||||||
let monitorList = await server.sendMonitorList(socket);
|
let monitorList = await server.sendMonitorList(socket);
|
||||||
await sendInfo(socket);
|
await Promise.allSettled([
|
||||||
await server.sendMaintenanceList(socket);
|
sendInfo(socket),
|
||||||
await sendNotificationList(socket);
|
server.sendMaintenanceList(socket),
|
||||||
await sendProxyList(socket);
|
sendNotificationList(socket),
|
||||||
await sendDockerHostList(socket);
|
sendProxyList(socket),
|
||||||
await sendAPIKeyList(socket);
|
sendDockerHostList(socket),
|
||||||
await sendRemoteBrowserList(socket);
|
sendAPIKeyList(socket),
|
||||||
|
sendRemoteBrowserList(socket),
|
||||||
await sleep(500);
|
]);
|
||||||
|
|
||||||
await StatusPage.sendStatusPageList(io, socket);
|
await StatusPage.sendStatusPageList(io, socket);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue