feat: add AI summary / transcript integration for recordings
Ported from greenlight-tm: when TRANSCRIPTION_API_URL and
TRANSCRIPTION_API_KEY are set in the .env and the per-room
"AI summary / transcript" setting is enabled, Redlight POSTs to
${TRANSCRIPTION_API_URL}/prompt (header X-Api-Key) as soon as the
"video" format of a recording becomes available.
- transcription.js: service with env gating, timeout and logging
- bbb.js: pass meta_bbb-recording-ready-url on meeting create when the
room has the setting enabled
- recordings.js: unauthenticated /recording-ready callback that
verifies BBB's signed_parameters JWT (HS256, shared secret), caches
the recording and requests the transcription once per recording
(deduped via transcript_requested_at)
- rooms: new recording_transcript column, accepted on create/update
- branding endpoint exposes transcriptionEnabled so the UI only shows
the toggle when the server is configured
- RoomDetail: toggle under "Allow recording" (disabled when recording
is off), de/en i18n
- chore: bump version to 2.4.0
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { getDb } from '../config/database.js';
|
||||
import { authenticateToken, requireAdmin } from '../middleware/auth.js';
|
||||
import { log } from '../config/logger.js';
|
||||
import { getOAuthConfig } from '../config/oauth.js';
|
||||
import { isTranscriptionEnabled } from '../config/transcription.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
@@ -121,6 +122,7 @@ router.get('/', async (req, res) => {
|
||||
oauthEnabled,
|
||||
oauthDisplayName,
|
||||
hideAppName: hideAppName === 'true',
|
||||
transcriptionEnabled: isTranscriptionEnabled(),
|
||||
});
|
||||
} catch (err) {
|
||||
log.branding.error('Get branding error:', err);
|
||||
|
||||
@@ -41,7 +41,7 @@ export function wellKnownHandler(req, res) {
|
||||
federation_api: '/api/federation',
|
||||
public_key: getPublicKey(),
|
||||
software: 'Redlight',
|
||||
version: '2.3.0',
|
||||
version: '2.4.0',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Router } from 'express';
|
||||
import { Router, urlencoded } from 'express';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { authenticateToken } from '../middleware/auth.js';
|
||||
import { getDb } from '../config/database.js';
|
||||
import { log } from '../config/logger.js';
|
||||
import { isTranscriptionEnabled, requestTranscription } from '../config/transcription.js';
|
||||
import {
|
||||
getRecordings,
|
||||
getRecordingByRecordId,
|
||||
@@ -9,6 +11,8 @@ import {
|
||||
publishRecording,
|
||||
} from '../config/bbb.js';
|
||||
|
||||
const BBB_SECRET = process.env.BBB_SECRET || '';
|
||||
|
||||
const router = Router();
|
||||
|
||||
/**
|
||||
@@ -176,6 +180,65 @@ async function fetchAndSyncRecordings(meetingID, fallbackName) {
|
||||
}
|
||||
}
|
||||
|
||||
// POST /api/recordings/recording-ready - BBB recording-ready callback (unauthenticated)
|
||||
// BBB posts `signed_parameters`, a JWT signed with the shared BBB secret.
|
||||
// Fires once per playback format; the transcription request is only sent when
|
||||
// the "video" format first becomes available and the room has the setting on.
|
||||
router.post('/recording-ready', urlencoded({ extended: false }), async (req, res) => {
|
||||
try {
|
||||
const signed = req.body?.signed_parameters;
|
||||
if (!signed || typeof signed !== 'string') {
|
||||
return res.status(400).json({ error: 'signed_parameters is required' });
|
||||
}
|
||||
|
||||
let payload;
|
||||
try {
|
||||
payload = jwt.verify(signed, BBB_SECRET, { algorithms: ['HS256'] });
|
||||
} catch {
|
||||
return res.status(403).json({ error: 'Invalid signature' });
|
||||
}
|
||||
|
||||
const recordId = payload.record_id;
|
||||
const meetingId = payload.meeting_id;
|
||||
if (!recordId || !meetingId) {
|
||||
return res.status(400).json({ error: 'record_id and meeting_id are required' });
|
||||
}
|
||||
|
||||
// Always answer 200 from here on so BBB does not keep retrying —
|
||||
// "nothing to do" is a valid outcome for this callback.
|
||||
const db = getDb();
|
||||
const room = await db.get('SELECT id, uid, name, recording_transcript FROM rooms WHERE uid = ?', [meetingId]);
|
||||
if (!room || !room.recording_transcript || !isTranscriptionEnabled()) {
|
||||
return res.json({});
|
||||
}
|
||||
|
||||
const rec = await getRecordingByRecordId(recordId).catch(() => null);
|
||||
if (!rec) return res.json({});
|
||||
|
||||
const formatted = formatBbbRecording(rec, room.name);
|
||||
const hasVideo = formatted.formats.some(f => f.type === 'video');
|
||||
|
||||
// Cache the recording so the dedupe marker below has a row to live on
|
||||
await upsertRecording(db, formatted);
|
||||
|
||||
if (!hasVideo) return res.json({});
|
||||
|
||||
// Dedupe: BBB fires the callback once per format
|
||||
const cached = await db.get('SELECT transcript_requested_at FROM recordings WHERE record_id = ?', [recordId]);
|
||||
if (cached?.transcript_requested_at) return res.json({});
|
||||
|
||||
const ok = await requestTranscription({ meetingId, recordingId: recordId });
|
||||
if (ok) {
|
||||
await db.run('UPDATE recordings SET transcript_requested_at = CURRENT_TIMESTAMP WHERE record_id = ?', [recordId]);
|
||||
}
|
||||
|
||||
res.json({});
|
||||
} catch (err) {
|
||||
log.recordings.error(`Recording-ready callback error: ${err.message}`);
|
||||
res.status(500).json({ error: 'Error processing recording-ready callback' });
|
||||
}
|
||||
});
|
||||
|
||||
// GET /api/recordings - Get recordings for a room (by meetingID/uid)
|
||||
router.get('/', authenticateToken, async (req, res) => {
|
||||
try {
|
||||
|
||||
@@ -193,6 +193,7 @@ router.post('/', authenticateToken, async (req, res) => {
|
||||
record_meeting,
|
||||
guest_access,
|
||||
moderator_code,
|
||||
recording_transcript,
|
||||
} = req.body;
|
||||
|
||||
if (!name || name.trim().length === 0) {
|
||||
@@ -227,8 +228,8 @@ router.post('/', authenticateToken, async (req, res) => {
|
||||
const db = getDb();
|
||||
|
||||
const result = await db.run(`
|
||||
INSERT INTO rooms (uid, name, user_id, welcome_message, max_participants, access_code, mute_on_join, require_approval, anyone_can_start, all_join_moderator, record_meeting, guest_access, moderator_code)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO rooms (uid, name, user_id, welcome_message, max_participants, access_code, mute_on_join, require_approval, anyone_can_start, all_join_moderator, record_meeting, guest_access, moderator_code, recording_transcript)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`, [
|
||||
uid,
|
||||
name.trim(),
|
||||
@@ -243,6 +244,7 @@ router.post('/', authenticateToken, async (req, res) => {
|
||||
record_meeting !== false ? 1 : 0,
|
||||
guest_access ? 1 : 0,
|
||||
moderator_code || null,
|
||||
recording_transcript ? 1 : 0,
|
||||
]);
|
||||
|
||||
const room = await db.get('SELECT * FROM rooms WHERE id = ?', [result.lastInsertRowid]);
|
||||
@@ -277,6 +279,7 @@ router.put('/:uid', authenticateToken, async (req, res) => {
|
||||
moderator_code,
|
||||
learning_analytics,
|
||||
analytics_visibility,
|
||||
recording_transcript,
|
||||
} = req.body;
|
||||
|
||||
// M12: field length limits (same as create)
|
||||
@@ -318,6 +321,7 @@ router.put('/:uid', authenticateToken, async (req, res) => {
|
||||
moderator_code = ?,
|
||||
learning_analytics = COALESCE(?, learning_analytics),
|
||||
analytics_visibility = COALESCE(?, analytics_visibility),
|
||||
recording_transcript = COALESCE(?, recording_transcript),
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE uid = ?
|
||||
`, [
|
||||
@@ -334,6 +338,7 @@ router.put('/:uid', authenticateToken, async (req, res) => {
|
||||
moderator_code !== undefined ? (moderator_code || null) : room.moderator_code,
|
||||
learning_analytics !== undefined ? (learning_analytics ? 1 : 0) : null,
|
||||
analytics_visibility && ['owner', 'shared'].includes(analytics_visibility) ? analytics_visibility : null,
|
||||
recording_transcript !== undefined ? (recording_transcript ? 1 : 0) : null,
|
||||
req.params.uid,
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user