diff --git a/CloudServer/server.js b/CloudServer/server.js index d213b87..2cf440f 100644 --- a/CloudServer/server.js +++ b/CloudServer/server.js @@ -259,8 +259,25 @@ function maybeSendStationUpdate(ws, stationName, stationVersion) { } } -function publishStationUpdate(req) { - const version = getLocalStationScriptVersion() || `build-${Date.now()}`; +async function fetchGiteaVersion() { + try { + const response = await fetch('https://gitea.fse-media.group/Henry_Du/CC-StationBroadcast/raw/branch/main/station_broadcast.lua'); + if (!response.ok) return null; + const text = await response.text(); + const match = text.match(/local\s+APP_VERSION_TEXT\s*=\s*["']([^"']+)["']/); + return match ? String(match[1]).trim() : null; + } catch (e) { + return null; + } +} + +async function publishStationUpdate(req) { + let version = await fetchGiteaVersion(); + if (!version) { + version = getLocalStationScriptVersion() || `build-${Date.now()}`; + log('WARN', `Failed to fetch Gitea version, falling back to local version: ${version}`); + } + const releaseId = String(Date.now()); stationUpdate = { version, @@ -2400,8 +2417,8 @@ app.get('/api/station-update', (req, res) => { }); }); -app.post('/api/station-updates/publish', (req, res) => { - const result = publishStationUpdate(req); +app.post('/api/station-updates/publish', async (req, res) => { + const result = await publishStationUpdate(req); res.json({ success: true, ...result diff --git a/station_broadcast.lua b/station_broadcast.lua index ebe48c5..968ba68 100644 --- a/station_broadcast.lua +++ b/station_broadcast.lua @@ -1,6 +1,6 @@ -- 1. Configuration & Constants -local APP_VERSION_TEXT = "v1.0.65" +local APP_VERSION_TEXT = "v1.0.66" local CONFIG = { CLOUD_URL = "ws://stabadmin.fse-media.group",