From f2f0aa87419973464c683ad4bd6b7817b8911335 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Fri, 3 May 2024 09:52:25 -0300 Subject: [PATCH] fix(accountLookup): fix user not found by using 'accountFromPubkey' --- src/controllers/api/accounts.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/api/accounts.ts b/src/controllers/api/accounts.ts index 70e6c6d..68edfbc 100644 --- a/src/controllers/api/accounts.ts +++ b/src/controllers/api/accounts.ts @@ -17,6 +17,7 @@ import { accountFromPubkey, renderAccount } from '@/views/mastodon/accounts.ts'; import { renderRelationship } from '@/views/mastodon/relationships.ts'; import { renderStatus } from '@/views/mastodon/statuses.ts'; import { hydrateEvents } from '@/storages/hydrate.ts'; +import { bech32ToPubkey } from '@/utils.ts'; const usernameSchema = z .string().min(1).max(30) @@ -76,8 +77,13 @@ const accountLookupController: AppController = async (c) => { if (event) { return c.json(await renderAccount(event)); } - - return c.json({ error: 'Could not find user.' }, 404); + try { + const pubkey = bech32ToPubkey(decodeURIComponent(acct)) as string; + return c.json(await accountFromPubkey(pubkey)); + } catch (e) { + console.log(e); + return c.json({ error: 'Could not find user.' }, 404); + } }; const accountSearchController: AppController = async (c) => {