toActor: don't require the nip05

Related: https://gitlab.com/soapbox-pub/ditto/-/issues/30
This commit is contained in:
Alex Gleason 2023-07-27 13:27:53 -05:00
parent 8019a8d958
commit 97d2298178
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 2 additions and 6 deletions

View File

@ -12,7 +12,7 @@ const actorController: AppController = async (c) => {
const event = await getAuthor(user.pubkey);
if (!event) return notFound(c);
const actor = await toActor(event);
const actor = await toActor(event, user.username);
if (!actor) return notFound(c);
return activityJson(c, actor);

View File

@ -6,13 +6,9 @@ import type { Event } from '@/event.ts';
import type { Actor } from '@/schemas/activitypub.ts';
/** Nostr metadata event to ActivityPub actor. */
async function toActor(event: Event<0>): Promise<Actor | undefined> {
async function toActor(event: Event<0>, username: string): Promise<Actor | undefined> {
const content = parseMetaContent(event);
if (!content.nip05) return;
const [username, hostname] = content.nip05.split('@');
if (hostname !== Conf.url.hostname) return;
return {
type: 'Person',
id: Conf.local(`/users/${username}`),