Release v1.3.3

This commit is contained in:
2026-07-21 01:55:10 +01:00
parent 6fb413cb6d
commit 6416dbfd99
8 changed files with 106 additions and 13 deletions
+51
View File
@@ -20,6 +20,57 @@ module.exports = function registerAdminManageRoutes(app, deps) {
const forwardPlayerCommand = deps.forwardPlayerCommand;
const PLAYER_PUBLIC_BASE_URL = deps.playerPublicBaseUrl;
async function fetchAllScreenSlugs() {
const [rows] = await pool.query('SELECT slug FROM screens ORDER BY slug ASC');
return (rows || [])
.map(function (row) {
return String(row && row.slug ? row.slug : '').trim();
})
.filter(Boolean);
}
app.post('/admin/commands', async function (req, res, next) {
try {
const command = String((req.body && req.body.command) || req.query.command || '').trim().toLowerCase();
const blackoutValue = req.body && Object.prototype.hasOwnProperty.call(req.body, 'blackout')
? req.body.blackout
: req.query.blackout;
if (!command) {
return res.status(400).json({ error: 'Command is required' });
}
if (command !== 'reload' && command !== 'blackout') {
return res.status(400).json({ error: 'Unsupported command' });
}
const slugs = await fetchAllScreenSlugs();
if (!slugs.length) {
await broadcastDashboardState();
return res.json({ ok: true, command: command, sent: 0 });
}
const payload = command === 'blackout'
? {
command: 'blackout',
blackout: blackoutValue === true || blackoutValue === 'true' || blackoutValue === '1' ? true : false
}
: 'reload';
const sentCount = await notifyPlayerScreens(slugs, payload);
await broadcastDashboardState();
return res.json({
ok: true,
command: command,
sent: sentCount,
blackout: command === 'blackout' ? Boolean(payload.blackout) : undefined
});
} catch (error) {
next(error);
}
});
app.post('/admin/playlists', async function (req, res, next) {
try {
const name = String(req.body.name || '').trim();