Scope live chat to the current match and save match history

This commit is contained in:
2026-10-07 00:40:20 -04:00
parent 8fcabe27fc
commit 2b8e102b86
14 changed files with 266 additions and 30 deletions
@@ -1,7 +1,7 @@
import { json } from '@sveltejs/kit';
import { getServer } from '$lib/server/fleet/servers.js';
import { gameLogKey, resolveLogPath, tailLog } from '$lib/server/fleet/logs.js';
import { serverChatTimeline } from '$lib/server/fleet/chat.js';
import { gameLogKey, resolveLogPath } from '$lib/server/fleet/logs.js';
import { collectServerChat } from '$lib/server/fleet/chat.js';
export async function GET({ params }: { params: { name: string } }) {
const headers = { 'Cache-Control': 'no-store' };
@@ -13,8 +13,7 @@ export async function GET({ params }: { params: { name: string } }) {
if (!path) return json({ ok: false, reason: 'Path traversal rejected' }, { status: 400, headers });
try {
const tail = await tailLog(path, 2000);
return json({ ok: true, entries: tail ? serverChatTimeline(server, tail) : [], missing: tail === null }, { headers });
return json({ ok: true, ...await collectServerChat(server) }, { headers });
} catch (error) {
console.error('Could not read server chat', error);
return json({ ok: false, reason: 'Could not read server chat' }, { status: 500, headers });