diff --git a/src/controllers/activitypub/actor.ts b/src/controllers/activitypub/actor.ts index c83acbe..e82a88a 100644 --- a/src/controllers/activitypub/actor.ts +++ b/src/controllers/activitypub/actor.ts @@ -1,7 +1,7 @@ -import { findUser } from '@/db/users.ts'; import { getAuthor } from '@/queries.ts'; import { activityJson } from '@/utils/api.ts'; import { renderActor } from '@/views/activitypub/actor.ts'; +import { localNip05Lookup } from '@/utils/nip05.ts'; import type { AppContext, AppController } from '@/app.ts'; @@ -9,13 +9,13 @@ const actorController: AppController = async (c) => { const username = c.req.param('username'); const { signal } = c.req.raw; - const user = await findUser({ username }, signal); - if (!user) return notFound(c); + const pointer = await localNip05Lookup(username); + if (!pointer) return notFound(c); - const event = await getAuthor(user.pubkey, { signal }); + const event = await getAuthor(pointer.pubkey, { signal }); if (!event) return notFound(c); - const actor = await renderActor(event, user.username); + const actor = await renderActor(event, username); if (!actor) return notFound(c); return activityJson(c, actor); diff --git a/src/controllers/well-known/webfinger.ts b/src/controllers/well-known/webfinger.ts index fa45aaa..1b353ee 100644 --- a/src/controllers/well-known/webfinger.ts +++ b/src/controllers/well-known/webfinger.ts @@ -1,6 +1,6 @@ import { Conf } from '@/config.ts'; -import { findUser } from '@/db/users.ts'; import { nip19, z } from '@/deps.ts'; +import { localNip05Lookup } from '@/utils/nip05.ts'; import type { AppContext, AppController } from '@/app.ts'; import type { Webfinger } from '@/schemas/webfinger.ts'; @@ -43,15 +43,15 @@ async function handleAcct(c: AppContext, resource: URL): Promise { } const [username, host] = result.data; - const user = await findUser({ username }); + const pointer = await localNip05Lookup(username); - if (!user) { + if (!pointer) { return c.json({ error: 'Not found' }, 404); } const json = renderWebfinger({ - pubkey: user.pubkey, - username: user.username, + pubkey: pointer.pubkey, + username, subject: `acct:${username}@${host}`, });