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 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) }),
eventsDB.query([{
authors: [pubkey],
store.query([{
kinds: [30078],
authors: [pubkey],
'#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,
}]),
]);
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);
};

View file

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

View file

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