Add account.source.ditto.captch_solved field

This commit is contained in:
Alex Gleason 2024-10-04 19:26:47 -05:00
parent 3b5b4cbd6b
commit 1cd7c99bda
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 23 additions and 4 deletions

View file

@ -49,17 +49,26 @@ const verifyCredentialsController: AppController = async (c) => {
const signer = c.get('signer')!; const signer = c.get('signer')!;
const pubkey = await signer.getPublicKey(); const pubkey = await signer.getPublicKey();
const eventsDB = await Storages.db(); const store = await Storages.db();
const [author, [settingsStore]] = await Promise.all([ const [author, [settingsStore], [captcha]] = await Promise.all([
getAuthor(pubkey, { signal: AbortSignal.timeout(5000) }), getAuthor(pubkey, { signal: AbortSignal.timeout(5000) }),
eventsDB.query([{ store.query([{
authors: [pubkey],
kinds: [30078], kinds: [30078],
authors: [pubkey],
'#d': ['pub.ditto.pleroma_settings_store'], '#d': ['pub.ditto.pleroma_settings_store'],
limit: 1, limit: 1,
}]), }]),
store.query([{
kinds: [1985],
authors: [Conf.pubkey],
'#L': ['pub.ditto.captcha'],
'#l': ['solved'],
'#p': [pubkey],
limit: 1,
}]),
]); ]);
const account = author const account = author
@ -74,6 +83,10 @@ const verifyCredentialsController: AppController = async (c) => {
} }
} }
if (captcha && account.source) {
account.source.ditto.captcha_solved = true;
}
return c.json(account); return c.json(account);
}; };

View file

@ -34,6 +34,9 @@ export interface MastodonAccount {
nostr: { nostr: {
nip05?: string; nip05?: string;
}; };
ditto: {
captcha_solved: boolean;
};
}; };
statuses_count: number; statuses_count: number;
uri: string; uri: string;

View file

@ -87,6 +87,9 @@ async function renderAccount(
nostr: { nostr: {
nip05, nip05,
}, },
ditto: {
captcha_solved: false,
},
} }
: undefined, : undefined,
statuses_count: event.author_stats?.notes_count ?? 0, statuses_count: event.author_stats?.notes_count ?? 0,