Add a P2P panel to the admin page
This commit is contained in:
@@ -2008,6 +2008,24 @@ const p2pRehydrate = createRehydrator({
|
||||
p2pDb, hub: p2pHub, enabled: () => P2P.enabled,
|
||||
hasServerCopy: async (id) => !!(await media.getReady(id).catch(() => null)),
|
||||
});
|
||||
// Admin: P2P overview + revoke (frontend/admin.html → Peer-to-peer).
|
||||
app.get('/api/admin/p2p', notes.requireAdminOrToken, async (c) => c.json({
|
||||
ok: true,
|
||||
config: {
|
||||
enabled: P2P.enabled, malwareScan: P2P.malwareScan, staleDays: P2P.staleDays,
|
||||
keepMinViews: P2P.keepMinViews, keepDays: P2P.keepDays, keepRecentDays: P2P.keepRecentDays,
|
||||
},
|
||||
stats: { ...(await p2pDb.p2pStats()), online: p2pHub.onlineCount(), intakeOpen: intake.openTickets(), intakeActive: intake.active() },
|
||||
recent: await p2pDb.recentContent(30),
|
||||
}, 200, { 'Cache-Control': 'no-store' }));
|
||||
app.post('/api/admin/p2p/revoke', notes.requireAdminOrToken, async (c) => {
|
||||
const body = await c.req.json().catch(() => ({}));
|
||||
const cid = String(body.cid || '').toLowerCase();
|
||||
if (!/^[0-9a-f]{64}$/.test(cid)) return c.json({ ok: false, error: 'bad cid' }, 400);
|
||||
await p2pDb.revokeContent(cid);
|
||||
console.warn(`[p2p] admin revoked ${cid.slice(0, 12)}`);
|
||||
return c.json({ ok: true });
|
||||
});
|
||||
|
||||
// ============================================================================
|
||||
// GET /sw.js — serve the service worker with BUILD_TAG injected
|
||||
|
||||
Reference in New Issue
Block a user