Refactor group command handling to enforce server control of turtle movement and reject legacy commands

This commit is contained in:
MayaTheShy
2026-02-20 03:44:11 -05:00
parent f6b39808aa
commit de58ec6b08

View File

@@ -1303,18 +1303,15 @@ app.post('/api/groups/:groupId/command', (req, res) => {
for (const member of members) {
const turtle = turtles.get(member.turtle_id);
if (turtle) {
// All group commands are state changes — server controls all movement
if (command === 'set_state' || command === 'setState') {
const stateName = param?.state || param;
const stateData = param?.data || {};
turtle.setState(stateName, stateData);
successCount++;
} else {
turtle.pendingLegacyCommands.push({
command,
param,
timestamp: Date.now()
});
console.log(`⚠️ Legacy group command rejected: ${command}`);
}
successCount++;
}
}