mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Switch captcha_solved from a label event to an n-tag on a user event
This commit is contained in:
parent
c5ddd2ebb7
commit
a484634d36
3 changed files with 7 additions and 35 deletions
|
|
@ -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<string, unknown> | 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);
|
||||
};
|
||||
|
|
@ -335,17 +326,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({
|
||||
|
|
|
|||
|
|
@ -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 { createAdminEvent, 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 });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import { renderEmojis } from '@/views/mastodon/emojis.ts';
|
|||
type ToAccountOpts = {
|
||||
withSource: true;
|
||||
settingsStore: Record<string, unknown> | 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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue