Add real time, match duration, and round context to chat

This commit is contained in:
2026-10-02 13:21:55 -04:00
parent 65d3a99846
commit d7b3e124e6
8 changed files with 505 additions and 26 deletions
@@ -0,0 +1,22 @@
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';
export async function GET({ params }: { params: { name: string } }) {
const headers = { 'Cache-Control': 'no-store' };
const server = getServer(params.name);
if (!server || server.destroyed_at) {
return json({ ok: false, reason: 'Server not found' }, { status: 404, headers });
}
const path = resolveLogPath(server.name, gameLogKey(server.name));
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 });
} catch (error) {
console.error('Could not read server chat', error);
return json({ ok: false, reason: 'Could not read server chat' }, { status: 500, headers });
}
}