Refactor group command handling to enforce server control of turtle movement and reject legacy commands
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user