diff --git a/src/controllers/api/accounts.ts b/src/controllers/api/accounts.ts index 50c7d140..b3c75ae5 100644 --- a/src/controllers/api/accounts.ts +++ b/src/controllers/api/accounts.ts @@ -51,7 +51,7 @@ const verifyCredentialsController: AppController = async (c) => { const store = await Storages.db(); - const [author, [settingsEvent], [captcha]] = await Promise.all([ + const [author, [settingsEvent]] = await Promise.all([ getAuthor(pubkey, { signal: AbortSignal.timeout(5000) }), store.query([{ @@ -60,15 +60,6 @@ const verifyCredentialsController: AppController = async (c) => { '#d': ['pub.ditto.pleroma_settings_store'], limit: 1, }]), - - store.query([{ - kinds: [1985], - authors: [Conf.pubkey], - '#L': ['pub.ditto.captcha'], - '#l': ['solved'], - '#p': [pubkey], - limit: 1, - }]), ]); let settingsStore: Record | undefined; @@ -79,8 +70,8 @@ const verifyCredentialsController: AppController = async (c) => { } const account = author - ? await renderAccount(author, { withSource: true, settingsStore, captcha }) - : await accountFromPubkey(pubkey, { withSource: true, settingsStore, captcha }); + ? await renderAccount(author, { withSource: true, settingsStore }) + : await accountFromPubkey(pubkey, { withSource: true, settingsStore }); return c.json(account); }; @@ -285,7 +276,6 @@ const updateCredentialsController: AppController = async (c) => { const pubkey = await signer.getPublicKey(); const body = await parseBody(c.req.raw); const result = updateCredentialsSchema.safeParse(body); - const store = await Storages.db(); if (!result.success) { return c.json(result.error, 422); @@ -335,17 +325,8 @@ const updateCredentialsController: AppController = async (c) => { c, ); - const [captcha] = await store.query([{ - kinds: [1985], - authors: [Conf.pubkey], - '#L': ['pub.ditto.captcha'], - '#l': ['solved'], - '#p': [pubkey], - limit: 1, - }]); - const settingsStore = result.data.pleroma_settings_store; - const account = await renderAccount(event, { withSource: true, settingsStore, captcha }); + const account = await renderAccount(event, { withSource: true, settingsStore }); if (settingsStore) { await createEvent({ diff --git a/src/controllers/api/captcha.ts b/src/controllers/api/captcha.ts index ef266745..1bb92118 100644 --- a/src/controllers/api/captcha.ts +++ b/src/controllers/api/captcha.ts @@ -4,7 +4,7 @@ import { z } from 'zod'; import { AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { createAdminEvent } from '@/utils/api.ts'; +import { updateUser } from '@/utils/api.ts'; interface Point { x: number; @@ -169,16 +169,7 @@ export const captchaVerifyController: AppController = async (c) => { if (solved) { captchas.delete(id); - - await createAdminEvent({ - kind: 1985, - tags: [ - ['L', 'pub.ditto.captcha'], - ['l', 'solved', 'pub.ditto.captcha'], - ['p', pubkey, Conf.relay], - ], - }, c); - + await updateUser(pubkey, { captcha_solved: true }, c); return new Response(null, { status: 204 }); } diff --git a/src/utils/api.ts b/src/utils/api.ts index c6d3c6b6..e7766979 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,4 +1,4 @@ -import { Context } from '@hono/hono'; +import { type Context } from '@hono/hono'; import { HTTPException } from '@hono/hono/http-exception'; import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; import Debug from '@soapbox/stickynotes/debug'; diff --git a/src/views/mastodon/accounts.ts b/src/views/mastodon/accounts.ts index 83bd705d..626203b8 100644 --- a/src/views/mastodon/accounts.ts +++ b/src/views/mastodon/accounts.ts @@ -1,4 +1,4 @@ -import { type NostrEvent, NSchema as n } from '@nostrify/nostrify'; +import { NSchema as n } from '@nostrify/nostrify'; import { escape } from 'entities'; import { nip19, UnsignedEvent } from 'nostr-tools'; @@ -15,7 +15,6 @@ import { renderEmojis } from '@/views/mastodon/emojis.ts'; type ToAccountOpts = { withSource: true; settingsStore: Record | undefined; - captcha: NostrEvent | undefined; } | { withSource?: false; }; @@ -91,7 +90,7 @@ async function renderAccount( nip05, }, ditto: { - captcha_solved: Boolean(opts.captcha), + captcha_solved: names.has('captcha_solved'), }, } : undefined,