2024-01-15 18:40:39 +00:00
|
|
|
import * as pipeline from '@/pipeline.ts';
|
2024-02-12 17:52:05 +00:00
|
|
|
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
2024-01-15 18:40:39 +00:00
|
|
|
import { type EventStub } from '@/utils/api.ts';
|
|
|
|
import { nostrNow } from '@/utils.ts';
|
|
|
|
|
|
|
|
switch (Deno.args[0]) {
|
|
|
|
case 'publish':
|
|
|
|
await publish(JSON.parse(Deno.args[1]));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log('Usage: deno run -A scripts/admin.ts <command>');
|
|
|
|
}
|
|
|
|
|
|
|
|
async function publish(t: EventStub) {
|
2024-02-12 17:52:05 +00:00
|
|
|
const signer = new AdminSigner();
|
|
|
|
|
|
|
|
const event = await signer.signEvent({
|
2024-01-15 18:40:39 +00:00
|
|
|
content: '',
|
|
|
|
created_at: nostrNow(),
|
|
|
|
tags: [],
|
|
|
|
...t,
|
|
|
|
});
|
|
|
|
|
2024-01-23 21:53:29 +00:00
|
|
|
await pipeline.handleEvent(event, AbortSignal.timeout(5000));
|
2024-01-15 18:40:39 +00:00
|
|
|
}
|