feat: add Settings live stream analysis button and diagnose Laya batch failure (#14)

Add a Settings action to manually rerun Live TV stream analysis:
it triggers an admin-guarded projection rebuild endpoint that
groups streams into logical channels (covering channels present
before the projection existed) and reruns language/Laya detection,
with progress presented via liveAnalysisPresentation. Harden the
Laya batch path that failed with 'Local AI language matching
failed' by surfacing the underlying cause and falling back to
standard matching cleanly. Guard admin-only rebuild through a new
authz helper and cover routes, service and presentation with tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
blomios
2026-10-02 16:09:13 +02:00
parent 9116d90526
commit 67d9869364
14 changed files with 386 additions and 25 deletions

View File

@ -0,0 +1,21 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const { isAdmin } = require('../server/authz');
const routeSource = fs.readFileSync(path.join(__dirname, '..', 'server', 'routes', 'live.js'), 'utf8');
test('projection status route requires authentication', () => {
assert.match(routeSource, /router\.get\('\/projection\/status', requireAuth,/);
});
test('projection rebuild route requires authentication and admin authorization', () => {
assert.match(routeSource, /router\.post\('\/projection\/rebuild', requireAuth, requireAdmin,/);
});
test('projection authorization distinguishes viewer and admin roles', () => {
assert.equal(isAdmin({ role: 'viewer' }), false);
assert.equal(isAdmin({ role: 'admin' }), true);
assert.equal(isAdmin(null), false);
});