Merge branch 'cli' into 'main'

Add a CLI task to publish events as the Ditto admin

See merge request soapbox-pub/ditto!101
This commit is contained in:
Alex Gleason 2024-01-15 18:43:10 +00:00
commit aa64029041
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,
title: meta.name ?? 'Ditto',
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,
max_toot_chars: Conf.postCharLimit,
configuration: {

View File

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