Merge branch 'sync' into 'develop'
Sync the user on verify_credentials Closes #11 See merge request soapbox-pub/ditto!17
This commit is contained in:
commit
f198779ebe
|
@ -2,7 +2,7 @@ import { type AppController } from '@/app.ts';
|
|||
import { type Filter, findReplyTag, z } from '@/deps.ts';
|
||||
import * as mixer from '@/mixer.ts';
|
||||
import * as pipeline from '@/pipeline.ts';
|
||||
import { getAuthor, getFollows } from '@/queries.ts';
|
||||
import { getAuthor, getFollows, syncUser } from '@/queries.ts';
|
||||
import { booleanParamSchema } from '@/schema.ts';
|
||||
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
|
||||
import { signEvent } from '@/sign.ts';
|
||||
|
@ -18,6 +18,8 @@ const createAccountController: AppController = (c) => {
|
|||
const verifyCredentialsController: AppController = async (c) => {
|
||||
const pubkey = c.get('pubkey')!;
|
||||
|
||||
await syncUser(pubkey);
|
||||
|
||||
const event = await getAuthor(pubkey);
|
||||
if (event) {
|
||||
return c.json(await toAccount(event, { withSource: true }));
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import * as client from '@/client.ts';
|
||||
import * as eventsDB from '@/db/events.ts';
|
||||
import { type Event, type Filter, findReplyTag } from '@/deps.ts';
|
||||
import * as mixer from '@/mixer.ts';
|
||||
|
@ -89,4 +90,21 @@ async function isLocallyFollowed(pubkey: string): Promise<boolean> {
|
|||
return Boolean(event);
|
||||
}
|
||||
|
||||
export { getAncestors, getAuthor, getDescendants, getEvent, getFeed, getFollows, getPublicFeed, isLocallyFollowed };
|
||||
/** Sync the user's state from other relays. */
|
||||
async function syncUser(pubkey: string): Promise<void> {
|
||||
await client.getFilters([
|
||||
{ authors: [pubkey], kinds: [0, 3, 10000, 10001, 10002] },
|
||||
], { timeout: 5000 });
|
||||
}
|
||||
|
||||
export {
|
||||
getAncestors,
|
||||
getAuthor,
|
||||
getDescendants,
|
||||
getEvent,
|
||||
getFeed,
|
||||
getFollows,
|
||||
getPublicFeed,
|
||||
isLocallyFollowed,
|
||||
syncUser,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue