Add API endpoint for remote reboot of CC:Tweaked computers
This commit is contained in:
@@ -519,6 +519,31 @@ app.post('/api/recipes/disable-all', (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remote reboot CC:Tweaked computers
|
||||||
|
app.post('/api/reboot', (req, res) => {
|
||||||
|
try {
|
||||||
|
const { target, commandId } = req.body || {};
|
||||||
|
|
||||||
|
const cached = checkIdempotent(commandId);
|
||||||
|
if (cached) return res.json(cached);
|
||||||
|
|
||||||
|
const validTargets = ['all', 'manager', 'client', 'turtle', 'bridge'];
|
||||||
|
const t = target || 'all';
|
||||||
|
// Allow valid role names or numeric computer IDs
|
||||||
|
if (!validTargets.includes(t) && !/^\d+$/.test(t)) {
|
||||||
|
return res.status(400).json({ error: 'Invalid target. Use: all, manager, client, turtle, bridge, or a computer ID' });
|
||||||
|
}
|
||||||
|
|
||||||
|
pushCommandToBridge({ type: 'command', action: 'reboot', commandId, target: t });
|
||||||
|
const result = { success: true, commandId, message: `Reboot sent to: ${t}` };
|
||||||
|
recordCommand(commandId, result);
|
||||||
|
console.log(`🔄 Reboot requested: target=${t}`);
|
||||||
|
res.json(result);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Sort barrel
|
// Sort barrel
|
||||||
app.post('/api/sort-barrel', (req, res) => {
|
app.post('/api/sort-barrel', (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user