feat: add poll start/end endpoints, poll.leading WS handler, and poll state persistence
Adds POST /:id/voting/start and POST /:id/voting/end endpoints that broadcast poll lifecycle events and persist poll state to the sessions table. The poll.leading WebSocket message is now handled server-side (rebroadcast + DB persist) with self-healing for polls started before the persistence columns existed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -63,6 +63,33 @@ function initializeDatabase() {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
// Poll state columns on sessions
|
||||
try {
|
||||
db.exec(`ALTER TABLE sessions ADD COLUMN poll_active INTEGER DEFAULT 0`);
|
||||
} catch (err) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
try {
|
||||
db.exec(`ALTER TABLE sessions ADD COLUMN poll_started_at TEXT`);
|
||||
} catch (err) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
try {
|
||||
db.exec(`ALTER TABLE sessions ADD COLUMN poll_leading_game_id INTEGER`);
|
||||
} catch (err) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
try {
|
||||
db.exec(`ALTER TABLE sessions ADD COLUMN poll_leading_label TEXT`);
|
||||
} catch (err) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
try {
|
||||
db.exec(`ALTER TABLE sessions ADD COLUMN poll_leading_votes INTEGER`);
|
||||
} catch (err) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
// Session games table
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS session_games (
|
||||
|
||||
Reference in New Issue
Block a user