From 2b6bf125e19e7ea63e074002526c90b269b3f37d Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Tue, 3 Dec 2024 18:23:13 -0300 Subject: [PATCH] refactor(updateCredentialsController): accountFromPubkey if the user has no kind 0 --- src/controllers/api/accounts.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/controllers/api/accounts.ts b/src/controllers/api/accounts.ts index 3dc1e815..3e054581 100644 --- a/src/controllers/api/accounts.ts +++ b/src/controllers/api/accounts.ts @@ -20,6 +20,7 @@ import { hydrateEvents } from '@/storages/hydrate.ts'; import { bech32ToPubkey } from '@/utils.ts'; import { addTag, deleteTag, findReplyTag, getTagSet } from '@/utils/tags.ts'; import { getPubkeysBySearch } from '@/utils/search.ts'; +import { MastodonAccount } from '@/entities/MastodonAccount.ts'; const usernameSchema = z .string().min(1).max(30) @@ -350,12 +351,14 @@ const updateCredentialsController: AppController = async (c) => { ); } - if (!event) { - return c.json({ error: 'Account not found.' }, 400); - } - const settingsStore = result.data.pleroma_settings_store; - const account = await renderAccount(event, { withSource: true, settingsStore }); + + let account: MastodonAccount; + if (event) { + account = await renderAccount(event, { withSource: true, settingsStore }); + } else { + account = await accountFromPubkey(pubkey, { withSource: true, settingsStore }); + } if (settingsStore) { await createEvent({