Add an endpoint to request a NIP-05 name
This commit is contained in:
parent
4361c340b0
commit
616c405f0f
|
@ -30,7 +30,7 @@ import { adminAccountAction, adminAccountsController } from '@/controllers/api/a
|
||||||
import { appCredentialsController, createAppController } from '@/controllers/api/apps.ts';
|
import { appCredentialsController, createAppController } from '@/controllers/api/apps.ts';
|
||||||
import { blocksController } from '@/controllers/api/blocks.ts';
|
import { blocksController } from '@/controllers/api/blocks.ts';
|
||||||
import { bookmarksController } from '@/controllers/api/bookmarks.ts';
|
import { bookmarksController } from '@/controllers/api/bookmarks.ts';
|
||||||
import { adminRelaysController, adminSetRelaysController } from '@/controllers/api/ditto.ts';
|
import { adminRelaysController, adminSetRelaysController, inviteRequestController } from '@/controllers/api/ditto.ts';
|
||||||
import { emptyArrayController, emptyObjectController, notImplementedController } from '@/controllers/api/fallback.ts';
|
import { emptyArrayController, emptyObjectController, notImplementedController } from '@/controllers/api/fallback.ts';
|
||||||
import { instanceController } from '@/controllers/api/instance.ts';
|
import { instanceController } from '@/controllers/api/instance.ts';
|
||||||
import { markersController, updateMarkersController } from '@/controllers/api/markers.ts';
|
import { markersController, updateMarkersController } from '@/controllers/api/markers.ts';
|
||||||
|
@ -239,6 +239,7 @@ app.delete('/api/v1/pleroma/admin/statuses/:id', requireRole('admin'), pleromaAd
|
||||||
app.get('/api/v1/admin/ditto/relays', requireRole('admin'), adminRelaysController);
|
app.get('/api/v1/admin/ditto/relays', requireRole('admin'), adminRelaysController);
|
||||||
app.put('/api/v1/admin/ditto/relays', requireRole('admin'), adminSetRelaysController);
|
app.put('/api/v1/admin/ditto/relays', requireRole('admin'), adminSetRelaysController);
|
||||||
|
|
||||||
|
app.post('/api/v1/ditto/nip05', requireSigner, inviteRequestController);
|
||||||
app.post('/api/v1/ditto/zap', requireSigner, zapController);
|
app.post('/api/v1/ditto/zap', requireSigner, zapController);
|
||||||
|
|
||||||
app.post('/api/v1/reports', requireSigner, reportController);
|
app.post('/api/v1/reports', requireSigner, reportController);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { AppController } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
import { Storages } from '@/storages.ts';
|
import { Storages } from '@/storages.ts';
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||||
|
import { createEvent } from '@/utils/api.ts';
|
||||||
|
|
||||||
const markerSchema = z.enum(['read', 'write']);
|
const markerSchema = z.enum(['read', 'write']);
|
||||||
|
|
||||||
|
@ -58,3 +59,25 @@ function renderRelays(event: NostrEvent): RelayEntity[] {
|
||||||
return acc;
|
return acc;
|
||||||
}, [] as RelayEntity[]);
|
}, [] as RelayEntity[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const inviteRequestSchema = z.object({
|
||||||
|
nip05: z.string().email(),
|
||||||
|
reason: z.string().max(500).optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const inviteRequestController: AppController = async (c) => {
|
||||||
|
const { nip05, reason } = inviteRequestSchema.parse(await c.req.json());
|
||||||
|
|
||||||
|
await createEvent({
|
||||||
|
kind: 3036,
|
||||||
|
content: reason,
|
||||||
|
tags: [
|
||||||
|
['r', nip05],
|
||||||
|
['L', 'nip05.domain'],
|
||||||
|
['l', nip05.split('@')[1], 'nip05.domain'],
|
||||||
|
['p', Conf.pubkey],
|
||||||
|
],
|
||||||
|
}, c);
|
||||||
|
|
||||||
|
return new Response('', { status: 204 });
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue