Scope live chat to the current match and save match history
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user