mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
31 lines
941 B
TypeScript
31 lines
941 B
TypeScript
import { DittoConf } from '@ditto/conf';
|
|
import { JsonParseStream } from '@std/json/json-parse-stream';
|
|
import { TextLineStream } from '@std/streams/text-line-stream';
|
|
|
|
import { AdminSigner } from '../packages/ditto/signers/AdminSigner.ts';
|
|
import { DittoStorages } from '../packages/ditto/DittoStorages.ts';
|
|
import { type EventStub } from '../packages/utils/api.ts';
|
|
import { nostrNow } from '../packages/ditto/utils.ts';
|
|
|
|
const conf = new DittoConf(Deno.env);
|
|
const signer = new AdminSigner(conf);
|
|
const storages = new DittoStorages(conf);
|
|
const store = await storages.db();
|
|
|
|
const readable = Deno.stdin.readable
|
|
.pipeThrough(new TextDecoderStream())
|
|
.pipeThrough(new TextLineStream())
|
|
.pipeThrough(new JsonParseStream());
|
|
|
|
for await (const t of readable) {
|
|
const event = await signer.signEvent({
|
|
content: '',
|
|
created_at: nostrNow(),
|
|
tags: [],
|
|
...t as EventStub,
|
|
});
|
|
|
|
await store.event(event);
|
|
}
|
|
|
|
Deno.exit(0);
|