mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
19 lines
552 B
TypeScript
19 lines
552 B
TypeScript
import { policyWorker } from '../packages/ditto/workers/policy.ts';
|
|
import { Storages } from '../packages/ditto/storages.ts';
|
|
|
|
const db = await Storages.db();
|
|
let count = 0;
|
|
|
|
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) {
|
|
await db.remove([{ ids: [event.id] }]);
|
|
count += 1;
|
|
}
|
|
}
|
|
|
|
console.log(`Cleaned up ${count} events from the db.`);
|
|
Deno.exit(0);
|