Merge branch 'nip11' into 'main'

Add NIP-11 support

See merge request soapbox-pub/ditto!81
This commit is contained in:
Alex Gleason 2023-12-20 03:21:00 +00:00
commit 5d53224a76
4 changed files with 29 additions and 4 deletions

View File

@ -10,8 +10,8 @@ const instanceController: AppController = (c) => {
return c.json({
uri: host,
title: 'Ditto',
description: 'An efficient and flexible social media server.',
short_description: 'An efficient and flexible social media server.',
description: 'Nostr and the Fediverse',
short_description: 'Nostr and the Fediverse',
registrations: Conf.registrations,
max_toot_chars: Conf.postCharLimit,
configuration: {

View File

@ -0,0 +1,19 @@
import { AppController } from '@/app.ts';
import { Conf } from '@/config.ts';
const relayInfoController: AppController = (c) => {
return c.json({
name: 'Ditto',
description: 'Nostr and the Fediverse.',
pubkey: '<administrative contact pubkey>',
contact: `mailto:${Conf.adminEmail}`,
supported_nips: [1, 5, 9, 11, 45, 46, 98],
software: 'Ditto',
version: '0.0.0',
limitation: {
// TODO.
},
});
};
export { relayInfoController };

View File

@ -1,3 +1,4 @@
import { relayInfoController } from '@/controllers/nostr/relay-info.ts';
import * as eventsDB from '@/db/events.ts';
import * as pipeline from '@/pipeline.ts';
import { jsonSchema } from '@/schema.ts';
@ -116,9 +117,14 @@ function prepareFilters(filters: ClientREQ[2][]): Filter[] {
}));
}
const relayController: AppController = (c) => {
const relayController: AppController = (c, next) => {
const upgrade = c.req.header('upgrade');
// NIP-11: https://github.com/nostr-protocol/nips/blob/master/11.md
if (c.req.header('accept') === 'application/nostr+json') {
return relayInfoController(c, next);
}
if (upgrade?.toLowerCase() !== 'websocket') {
return c.text('Please use a Nostr client to connect.', 400);
}

View File

@ -9,7 +9,7 @@ export {
} from 'https://deno.land/x/hono@v3.10.1/mod.ts';
export { cors, logger, serveStatic } from 'https://deno.land/x/hono@v3.10.1/middleware.ts';
export { z } from 'https://deno.land/x/zod@v3.21.4/mod.ts';
export { Author, RelayPool } from 'https://dev.jspm.io/nostr-relaypool@0.6.30';
export { RelayPool } from 'https://dev.jspm.io/nostr-relaypool@0.6.30';
export {
type Event,
type EventTemplate,