move neato and lift into activities

This commit is contained in:
legop3
2026-06-23 12:36:21 -04:00
parent 0a351b9a46
commit 5634004ebd
9 changed files with 72 additions and 81 deletions
+5 -4
View File
@@ -1,11 +1,10 @@
// Lift Service
// Purpose: Provides a single global, verified-gated lift controller with serialized interlocked motion.
// Purpose: Provides a single global lift controller with serialized interlocked motion.
// Scope: Owns lift command sequencing, anti-spam controls, HA wiring, and shared state publication for UI sync.
const EventEmitter = require('events');
const io = require('../../globals/io');
const logger = require('../../globals/logger').child('liftService');
const { loadConfig } = require('../../helpers/configLoader');
const { isVerified } = require('../verificationService');
const { getMode, MODES } = require('../modeManager');
const { isLockdownAdmin } = require('../roleService');
const {
@@ -183,7 +182,8 @@ io.on('connection', (socket) => {
if (getMode() === MODES.LOCKDOWN && !isLockdownAdmin(socket)) {
throw new Error('Server in lockdown');
}
if (!isVerified(socket)) throw new Error('VIP verification required');
// Lift movement is now a public activity feature. Lockdown still wins
// above because that mode is the global safety/admin gate for the room.
const resp = await moveUp(socket.id || 'socket');
cb({ success: true, ...resp });
} catch (err) {
@@ -196,7 +196,8 @@ io.on('connection', (socket) => {
if (getMode() === MODES.LOCKDOWN && !isLockdownAdmin(socket)) {
throw new Error('Server in lockdown');
}
if (!isVerified(socket)) throw new Error('VIP verification required');
// Public access intentionally mirrors lift:up so both directions share
// the same policy and cannot drift into different permission behavior.
const resp = await moveDown(socket.id || 'socket');
cb({ success: true, ...resp });
} catch (err) {
+8 -15
View File
@@ -265,9 +265,8 @@ io.on('connection', (socket) => {
socket.on('neato:start', async (_, cb = () => {}) => {
try {
assertLockdownAccess();
if (!isVerified(socket)) {
throw new Error('VIP verification required');
}
// Neato commands are public activity features. The lockdown check above
// remains the room-wide safety/admin gate when the server is restricted.
await startCleaning();
cb({ success: true });
} catch (err) {
@@ -278,9 +277,7 @@ io.on('connection', (socket) => {
socket.on('neato:sendHome', async (_, cb = () => {}) => {
try {
assertLockdownAccess();
if (!isVerified(socket)) {
throw new Error('VIP verification required');
}
// Keep send-home public for consistency with the rest of the Neato card.
await sendHome();
cb({ success: true });
} catch (err) {
@@ -291,9 +288,7 @@ io.on('connection', (socket) => {
socket.on('neato:locate', async (_, cb = () => {}) => {
try {
assertLockdownAccess();
if (!isVerified(socket)) {
throw new Error('VIP verification required');
}
// Locate is a public activity action; lockdown still blocks it above.
await locateRobot();
cb({ success: true });
} catch (err) {
@@ -304,9 +299,8 @@ io.on('connection', (socket) => {
socket.on('neato:clearErrors', async (_, cb = () => {}) => {
try {
assertLockdownAccess();
if (!isVerified(socket)) {
throw new Error('VIP verification required');
}
// Error clearing is grouped with the public Neato controls so the UI does
// not show a button that only some public users can actually run.
await clearErrors();
cb({ success: true });
} catch (err) {
@@ -317,9 +311,8 @@ io.on('connection', (socket) => {
socket.on('neato:powerCycle', async (_, cb = () => {}) => {
try {
assertLockdownAccess();
if (!isVerified(socket)) {
throw new Error('VIP verification required');
}
// Power cycle follows the same public policy as the rest of the card;
// operational safety remains controlled by lockdown mode.
await powerCycle();
cb({ success: true });
} catch (err) {