mirror of
https://github.com/aljazceru/ditto.git
synced 2026-02-06 05:54:20 +01:00
Merge branch 'ditto-retroactive-policies' into 'main'
add cleanup script (apply policy to events created before it applied) Closes #232 See merge request soapbox-pub/ditto!590
This commit is contained in:
19
scripts/db-policy.ts
Normal file
19
scripts/db-policy.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { policyWorker } from '@/workers/policy.ts';
|
||||
import { Storages } from '@/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);
|
||||
Reference in New Issue
Block a user