service live configslop

This commit is contained in:
legop3
2026-09-14 17:56:53 -04:00
parent 881583ee0a
commit 91e0cc3886
69 changed files with 1188 additions and 619 deletions
+17 -10
View File
@@ -4,9 +4,13 @@
const { loadConfig } = require('../../configuration');
const { getConfiguredSocials } = require('./configuration');
const config = loadConfig();
const serverTimezone = config.timezone || null;
const configuredSocials = getConfiguredSocials(config);
function getServerTimezone() {
return loadConfig().timezone || null;
}
function getConfiguredSessionSocials() {
return getConfiguredSocials(loadConfig());
}
/*
The driver ad is trusted deployment content supplied by the server operator.
Normalize both values at the server boundary so every browser receives a
@@ -16,19 +20,22 @@ const configuredSocials = getConfiguredSocials(config);
An empty HTML string disables the card; the title alone must never leave an
empty panel at the bottom of the driver layout.
*/
const driverAd = {
title: typeof config.driverAd?.title === 'string' ? config.driverAd.title.trim() : '',
html: typeof config.driverAd?.html === 'string' ? config.driverAd.html.trim() : '',
};
function getDriverAd() {
const configured = loadConfig().driverAd;
return {
title: typeof configured?.title === 'string' ? configured.title.trim() : '',
html: typeof configured?.html === 'string' ? configured.html.trim() : '',
};
}
const ACTIVITY_SYNC_COOLDOWN_MS = 3000;
const GPIO_TOGGLE_SYNC_COOLDOWN_MS = 1000;
const PERIODIC_SYNC_MS = 20000;
module.exports = {
serverTimezone,
configuredSocials,
driverAd,
getServerTimezone,
getConfiguredSessionSocials,
getDriverAd,
ACTIVITY_SYNC_COOLDOWN_MS,
GPIO_TOGGLE_SYNC_COOLDOWN_MS,
PERIODIC_SYNC_MS,
+15 -8
View File
@@ -3,7 +3,7 @@
// Scope: Keeps runtime behavior unchanged while isolating responsibilities into a clear module boundary.
const io = require('../../globals/io');
const logger = require('../../globals/logger').child('sessionService');
const { getFeatureFlags } = require('../../configuration');
const { getFeatureFlags, configurationEvents } = require('../../configuration');
const { getRole, isAdmin, roleEvents } = require('../roleService');
const { getMode, modeEvents } = require('../modeManager');
const roverManager = require('../roverManager');
@@ -58,9 +58,9 @@ const { getAudioLevels, getAudioAdjustmentStateForSocket, audioLevelsEvents } =
const { getButtonBoxState } = require('../buttonBoxService');
const { getState: getInterInstanceState, interInstanceEvents } = require('../interInstanceService');
const {
serverTimezone,
configuredSocials,
driverAd,
getServerTimezone,
getConfiguredSessionSocials,
getDriverAd,
ACTIVITY_SYNC_COOLDOWN_MS,
GPIO_TOGGLE_SYNC_COOLDOWN_MS,
PERIODIC_SYNC_MS,
@@ -71,7 +71,6 @@ const {
filterActiveDriversForSocket,
filterTurnQueuesForSocket,
} = require('./filters');
logger.info('Socials config loaded:', configuredSocials?.length ? `${configuredSocials.length} entries` : 'not configured');
const SPECTATOR_ACCESS_NAMESPACE = 'spectatorAccess';
@@ -195,7 +194,8 @@ function buildSession(socket) {
const assignmentRoverId = filterVisibleRoverId(socket, verifiedAssignmentRover);
const activeDrivers = filterActiveDriversForSocket(getActiveDrivers(), socket);
const turnQueues = filterTurnQueuesForSocket(getTurnQueues(), socket);
const socials = features.socials && configuredSocials?.length ? configuredSocials : [];
const configuredSocials = getConfiguredSessionSocials();
const socials = features.socials && configuredSocials.length ? configuredSocials : [];
return {
socketId: socket?.id || null,
role: getRole(socket),
@@ -240,8 +240,8 @@ function buildSession(socket) {
session payload makes the server configuration the single source of
truth and avoids a separate endpoint for one small optional card.
*/
driverAd,
timezone: serverTimezone,
driverAd: getDriverAd(),
timezone: getServerTimezone(),
identity: getIdentitySummary(socket),
verification: getVerificationStateForSocket(socket),
moderation: getModerationStateForSocket(socket),
@@ -510,6 +510,13 @@ interInstanceEvents.on('change', () => {
syncAll();
});
configurationEvents.on('applied', () => {
// Feature switches and passive presentation values share the session payload.
// Broadcast only after all affected service reloads finish so clients never
// see a new feature map paired with an old service runtime.
syncAll();
});
// sync all sockets 20 seconds
// setInterval(() => {
// logger.info('Periodic session sync for all clients');