Retain host and server scope during investigations
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { error, json } from '@sveltejs/kit';
|
||||
import { listHostOperationHistory } from '$lib/server/hosts/index.js';
|
||||
import { requireManagementOrigin } from '$lib/server/hosts/http.js';
|
||||
import { isHostOperationFilter } from '$lib/hosts.js';
|
||||
import { hostOperationScope, isHostOperationFilter } from '$lib/hosts.js';
|
||||
|
||||
export function GET({ request }: { request: Request }) {
|
||||
requireManagementOrigin(request);
|
||||
@@ -10,5 +10,9 @@ export function GET({ request }: { request: Request }) {
|
||||
const filter = params.get('filter') ?? 'important';
|
||||
if (!Number.isSafeInteger(page) || page < 1) error(400, 'Invalid operation history page.');
|
||||
if (!isHostOperationFilter(filter)) error(400, 'Invalid operation history filter.');
|
||||
return json(listHostOperationHistory(page, filter), { headers: { 'Cache-Control': 'no-store' } });
|
||||
const scope = hostOperationScope(params);
|
||||
for (const key of ['host', 'server'] as const) {
|
||||
if (params.has(key) && params.get(key) !== scope[key]) error(400, 'Invalid operation history scope.');
|
||||
}
|
||||
return json(listHostOperationHistory(page, filter, scope), { headers: { 'Cache-Control': 'no-store' } });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user