mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
22 lines
572 B
TypeScript
22 lines
572 B
TypeScript
import { policyWorker } from '@/workers/policy.ts';
|
|
import { Storages } from '@/storages.ts';
|
|
|
|
const db = await Storages.db();
|
|
const ids = [];
|
|
|
|
for await (const msg of db.req([{}])) {
|
|
const [type, , event] = msg;
|
|
if (type === 'EOSE') console.log('EOSE');
|
|
if (type !== 'EVENT') continue;
|
|
const [, , ok] = await policyWorker.call(event, AbortSignal.timeout(5000));
|
|
if (!ok) ids.push(event.id);
|
|
}
|
|
|
|
try {
|
|
await db.remove([{ ids }]);
|
|
console.log(`Cleaned up ${ids.length} events from the db.`);
|
|
Deno.exit(0);
|
|
} catch (e) {
|
|
console.error(e);
|
|
Deno.exit(1);
|
|
}
|