From afd0ae6428ab6627cd14d751df00d5f0c6e63518 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 27 Dec 2024 14:21:18 -0600 Subject: [PATCH] Initial support for setting a server identifier --- server/client.js | 1 + server/notification-providers/slack.js | 4 ++++ server/notification-providers/smtp.js | 5 +++++ src/components/settings/General.vue | 21 +++++++++++++++++++++ src/layouts/Layout.vue | 18 +++++++++++++++--- src/mixins/public.js | 12 ++++++++++++ src/pages/Setup.vue | 2 +- src/pages/SetupDatabase.vue | 2 +- 8 files changed, 60 insertions(+), 5 deletions(-) diff --git a/server/client.js b/server/client.js index 72f0a4e8e..421f89441 100644 --- a/server/client.js +++ b/server/client.js @@ -160,6 +160,7 @@ async function sendInfo(socket, hideVersion = false) { isContainer, dbType, primaryBaseURL: await setting("primaryBaseURL"), + serverIdentifier: await setting("serverIdentifier"), serverTimezone: await server.getTimezone(), serverTimezoneOffset: server.getTimezoneOffset(), }); diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index 5e25a1fbc..202aef12b 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -142,8 +142,12 @@ class Slack extends NotificationProvider { } const baseURL = await setting("primaryBaseURL"); + const serverIdentifier = await setting("serverIdentifier"); const title = "Uptime Kuma Alert"; + if (serverIdentifier) { + title = title + " (" + serverIdentifier + ")" + } let data = { "channel": notification.slackchannel, "username": notification.slackusername, diff --git a/server/notification-providers/smtp.js b/server/notification-providers/smtp.js index 9f3defa5e..4e614fa06 100644 --- a/server/notification-providers/smtp.js +++ b/server/notification-providers/smtp.js @@ -46,6 +46,11 @@ class SMTP extends NotificationProvider { let body = msg; if (heartbeatJSON) { body = `${msg}\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`; + + const serverIdentifier = await setting("serverIdentifier"); + if (serverIdentifier) { + body = body + `\nServer Identifier: ${serverIdentifier}` + } } // subject and body are templated if ((monitorJSON && heartbeatJSON) || msg.endsWith("Testing")) { diff --git a/src/components/settings/General.vue b/src/components/settings/General.vue index 487c3ba3a..82df5e958 100644 --- a/src/components/settings/General.vue +++ b/src/components/settings/General.vue @@ -132,6 +132,27 @@
+ +
+ + +
+ +
+ +
+
+