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) {
|
for (const member of members) {
|
||||||
const turtle = turtles.get(member.turtle_id);
|
const turtle = turtles.get(member.turtle_id);
|
||||||
if (turtle) {
|
if (turtle) {
|
||||||
|
// All group commands are state changes — server controls all movement
|
||||||
if (command === 'set_state' || command === 'setState') {
|
if (command === 'set_state' || command === 'setState') {
|
||||||
const stateName = param?.state || param;
|
const stateName = param?.state || param;
|
||||||
const stateData = param?.data || {};
|
const stateData = param?.data || {};
|
||||||
turtle.setState(stateName, stateData);
|
turtle.setState(stateName, stateData);
|
||||||
|
successCount++;
|
||||||
} else {
|
} else {
|
||||||
turtle.pendingLegacyCommands.push({
|
console.log(`⚠️ Legacy group command rejected: ${command}`);
|
||||||
command,
|
|
||||||
param,
|
|
||||||
timestamp: Date.now()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
successCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user