From be26bb75d9a54debad31a3914bbf072bc929cc7c Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 14 Jul 2023 18:02:49 +0800 Subject: [PATCH] Update version handling --- server/client.js | 15 ++++++++++++--- server/server.js | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/client.js b/server/client.js index 3efbe8fdc..2e3bd43b7 100644 --- a/server/client.js +++ b/server/client.js @@ -141,12 +141,21 @@ async function sendAPIKeyList(socket) { /** * Emits the version information to the client. * @param {Socket} socket Socket.io socket instance + * @param {boolean} hideVersion * @returns {Promise} */ -async function sendInfo(socket) { +async function sendInfo(socket, hideVersion = false) { + let version; + let latestVersion; + + if (!hideVersion) { + version = checkVersion.version; + latestVersion = checkVersion.latestVersion; + } + socket.emit("info", { - version: checkVersion.version, - latestVersion: checkVersion.latestVersion, + version, + latestVersion, primaryBaseURL: await setting("primaryBaseURL"), serverTimezone: await server.getTimezone(), serverTimezoneOffset: server.getTimezoneOffset(), diff --git a/server/server.js b/server/server.js index b9d618f51..9e34b4e7e 100644 --- a/server/server.js +++ b/server/server.js @@ -263,7 +263,7 @@ let needSetup = false; log.info("server", "Adding socket handler"); io.on("connection", async (socket) => { - sendInfo(socket); + sendInfo(socket, true); if (needSetup) { log.info("server", "Redirect to setup page"); @@ -1651,6 +1651,7 @@ async function afterLogin(socket, user) { socket.join(user.id); let monitorList = await server.sendMonitorList(socket); + sendInfo(socket); server.sendMaintenanceList(socket); sendNotificationList(socket); sendProxyList(socket);