Something went wrong. Try again.
FlockOff is a mass-block tool for the Atmosphere flockoff.app
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { restoreAgent } from '@/lib/oauth'import { requireSession } from '@/lib/session'import { getBlockEvent } from '@/lib/lexicon'import { isEventJobRunning } from '@/lib/queue'
// Validate the status of a block event by reading the PDS record and checking// if there's an active in-memory job. Tells the client whether blocks are still// processing, complete, or if some failed and need retrying.export async function GET(request: Request) { const { searchParams } = new URL(request.url) const rkey = searchParams.get('rkey')
if (!rkey) { return Response.json({ error: 'rkey is required' }, { status: 400 }) }
let session: { did: string } try { session = await requireSession() } catch { return Response.json({ error: 'Not authenticated' }, { status: 401 }) }
try { const agent = await restoreAgent(session.did) const { record } = await getBlockEvent(agent, session.did, rkey)
const isRunning = isEventJobRunning(rkey) const hasPending = record.pendingDids.length > 0
// Check if there's an active in-memory job for this event // (a job could be running but we don't expose job IDs from this endpoint) const status: 'pending' | 'complete' | 'partial' = hasPending ? 'pending' : record.failedDids.length > 0 ? 'partial' : 'complete'
return Response.json({ status, total: record.stats?.total ?? (record.blockedDids.length + record.failedDids.length + record.pendingDids.length), completed: record.blockedDids.length, failed: record.failedDids.length, pending: record.pendingDids.length, isRunning, failedDids: record.failedDids, }) } catch (err) { console.error('[api/blocks/validate]', err) return Response.json({ error: 'Failed to fetch event record' }, { status: 500 }) }}