diff --git a/src/controllers/activitypub/actor.ts b/src/controllers/activitypub/actor.ts index 9231344..8d09255 100644 --- a/src/controllers/activitypub/actor.ts +++ b/src/controllers/activitypub/actor.ts @@ -3,21 +3,23 @@ import { db } from '@/db.ts'; import { toActor } from '@/transformers/nostr-to-activitypub.ts'; import { activityJson } from '@/utils.ts'; -import type { AppController } from '@/app.ts'; +import type { AppContext, AppController } from '@/app.ts'; const actorController: AppController = async (c) => { - const notFound = c.json({ error: 'Not found' }, 404); - const username = c.req.param('username'); const user = await db.users.findFirst({ where: { username } }); const event = await getAuthor(user.pubkey); - if (!event) return notFound; + if (!event) return notFound(c); const actor = await toActor(event); - if (!actor) return notFound; + if (!actor) return notFound(c); return activityJson(c, actor); }; +function notFound(c: AppContext) { + return c.json({ error: 'Not found' }, 404); +} + export { actorController };