feat: add multi-user support for favorites management and room clock synchronization

- Implemented a new API endpoint for retrieving and managing user favorites in /api/users.
- Added functionality for admins to edit the shared "main" user's favorites.
- Created a one-shot DB smoke test script for verifying multi-user kiosk migrations.
- Introduced a RoomClock class for synchronizing server time across clients using WebSocket.
This commit is contained in:
Marco Mooren
2026-05-13 13:53:12 +02:00
parent f6cdfd975c
commit 29423288ca
41 changed files with 4229 additions and 275 deletions

View File

@@ -0,0 +1,24 @@
// One-shot DB smoke test for the multi-user kiosk migrations.
import { initDb, getDb } from '../db/index.js';
import { ensureMainUser, getMainUser } from '../auth.js';
import { app } from 'electron';
initDb(process.env.DB_PATH || './data/db/oradio.sqlite');
const db = getDb();
ensureMainUser(process.env.MAIN_USER || 'morphix');
const userCols = db.prepare("PRAGMA table_info(users)").all().map((c) => c.name);
const deviceCols = db.prepare("PRAGMA table_info(kiosk_devices)").all().map((c) => c.name);
const wlCols = db.prepare("PRAGMA table_info(kiosk_device_users)").all().map((c) => c.name);
const roomStateCols = db.prepare("PRAGMA table_info(room_state)").all().map((c) => c.name);
const users = db.prepare('SELECT id, username, role, is_main, avatar_color, avatar_emoji FROM users').all();
const mainCount = db.prepare('SELECT count(*) AS c FROM users WHERE is_main = 1').get().c;
console.log('users cols: ', userCols.join(', '));
console.log('kiosk_devices cols: ', deviceCols.join(', '));
console.log('kiosk_device_users: ', wlCols.join(', '));
console.log('room_state cols: ', roomStateCols.join(', '));
console.log('users: ', JSON.stringify(users, null, 2));
console.log('main user count: ', mainCount);
console.log('getMainUser(): ', getMainUser());
app.quit();