mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-17 21:44:23 +01:00
Add a CLI task to publish events as the Ditto admin
This commit is contained in:
23
scripts/admin.ts
Normal file
23
scripts/admin.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as pipeline from '@/pipeline.ts';
|
||||
import { signAdminEvent } from '@/sign.ts';
|
||||
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) {
|
||||
const event = await signAdminEvent({
|
||||
content: '',
|
||||
created_at: nostrNow(),
|
||||
tags: [],
|
||||
...t,
|
||||
});
|
||||
|
||||
await pipeline.handleEvent(event);
|
||||
}
|
||||
Reference in New Issue
Block a user