Implement Owner Panel features and maintenance mode handling

- Introduced the Owner Panel with new routes and UI components for managing guilds, user blacklists, feature flags, and bot presence.
- Added maintenance mode functionality to prevent non-owner users from executing commands during maintenance periods.
- Enhanced localization with new keys for Owner Panel features in both English and German.
- Updated job processing to include a presence refresh job, ensuring the bot's status is regularly updated.
- Improved environment configuration to support owner user IDs for access control.
This commit is contained in:
smueller
2026-07-22 16:10:30 +02:00
parent bcbfa07697
commit 8a8aefb4fb
42 changed files with 2385 additions and 50 deletions

View File

@@ -0,0 +1,48 @@
import { NextResponse } from 'next/server';
import { toApiErrorResponse } from '@/lib/auth';
import { getAllQueueStats, retryFailedJobs } from '@/lib/owner-jobs';
import { writeOwnerAudit } from '@/lib/owner-audit';
import { requireOwner } from '@/lib/owner-auth';
import { prisma } from '@/lib/prisma';
export async function GET() {
try {
await requireOwner('SUPPORT');
const [queues, migrations] = await Promise.all([
getAllQueueStats(),
prisma.$queryRaw<Array<{ migration_name: string; finished_at: Date | null }>>`
SELECT migration_name, finished_at FROM "_prisma_migrations" ORDER BY finished_at DESC NULLS LAST
`
]);
return NextResponse.json({
queues,
migrations: migrations.map((row) => ({
name: row.migration_name,
finishedAt: row.finished_at?.toISOString() ?? null
}))
});
} catch (error) {
return toApiErrorResponse(error);
}
}
export async function POST(request: Request) {
try {
const session = await requireOwner('ADMIN');
const body = (await request.json()) as { queueName?: string };
if (!body.queueName) {
return NextResponse.json({ error: 'queueName required' }, { status: 400 });
}
const retried = await retryFailedJobs(body.queueName);
await writeOwnerAudit(prisma, {
actorUserId: session.user.id,
action: 'jobs.retryFailed',
targetType: 'Queue',
targetId: body.queueName,
after: { retried }
});
return NextResponse.json({ retried });
} catch (error) {
return toApiErrorResponse(error);
}
}