Add song-level report triage
This commit is contained in:
@@ -762,12 +762,24 @@ export function registerNoteRoutes(app, deps) {
|
||||
|
||||
app.get('/api/admin/flags', requireAdminOrToken, async (c) => {
|
||||
const status = ['open', 'resolved', 'all'].includes(c.req.query('status')) ? c.req.query('status') : 'open';
|
||||
const olderThanDays = Math.max(0, Math.min(3650, Number(c.req.query('olderThanDays')) || 0));
|
||||
const olderThan = olderThanDays ? Math.floor(Date.now() / 1000) - olderThanDays * 86400 : 0;
|
||||
const cache = new Map();
|
||||
const flags = [];
|
||||
for (const f of await db.listAllFlags({ status, limit: 300 })) {
|
||||
for (const f of await db.listAllFlags({ status, limit: 300, olderThan })) {
|
||||
flags.push({ ...f, ...(await songLabel(f.videoId, cache)) });
|
||||
}
|
||||
return c.json({ ok: true, open: await db.countOpenFlags(), flags });
|
||||
return c.json({ ok: true, open: await db.countOpenFlags(), flags, olderThanDays });
|
||||
});
|
||||
|
||||
app.post('/api/admin/flags/song/:videoId/resolve', requireAdmin, async (c) => {
|
||||
const videoId = c.req.param('videoId');
|
||||
if (badId(videoId)) return c.json({ ok: false, error: 'invalid video id' }, 400);
|
||||
const flags = await db.listFlagsForVideo(videoId, 'open');
|
||||
let resolved = 0;
|
||||
for (const flag of flags) if (await db.setFlagStatus(flag.id, 'resolved', 'admin')) resolved++;
|
||||
if (resolved) await audit(db, 'admin', 'report.song.resolve', videoId, { resolved });
|
||||
return c.json({ ok: true, resolved, open: await db.countOpenFlags() });
|
||||
});
|
||||
|
||||
app.post('/api/admin/flags/:fid', requireAdmin, async (c) => {
|
||||
|
||||
Reference in New Issue
Block a user