Add a CLI task to publish events as the Ditto admin

This commit is contained in:
Alex Gleason 2024-01-15 12:40:39 -06:00
parent 3a654b8ff2
commit e16e81da86
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 25 additions and 1 deletions

23
scripts/admin.ts Normal file
View 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);
}

View File

@ -16,7 +16,7 @@ const instanceController: AppController = async (c) => {
uri: host, uri: host,
title: meta.name ?? 'Ditto', title: meta.name ?? 'Ditto',
description: meta.about ?? 'Nostr and the Fediverse', description: meta.about ?? 'Nostr and the Fediverse',
short_description: meta.tagline ?? 'Nostr and the Fediverse', short_description: meta.tagline ?? meta.about ?? 'Nostr and the Fediverse',
registrations: Conf.registrations, registrations: Conf.registrations,
max_toot_chars: Conf.postCharLimit, max_toot_chars: Conf.postCharLimit,
configuration: { configuration: {

View File

@ -179,6 +179,7 @@ export {
activityJson, activityJson,
createAdminEvent, createAdminEvent,
createEvent, createEvent,
type EventStub,
localRequest, localRequest,
paginated, paginated,
type PaginationParams, type PaginationParams,