Implement familiar followers

This commit is contained in:
Alex Gleason
2024-05-24 22:30:56 -05:00
parent ca755b6d77
commit 622a2b2a4f
2 changed files with 25 additions and 0 deletions

View File

@@ -402,6 +402,28 @@ const favouritesController: AppController = async (c) => {
return paginated(c, events1, statuses);
};
const familiarFollowersController: AppController = async (c) => {
const store = await Storages.db();
const signer = c.get('signer')!;
const pubkey = await signer.getPublicKey();
const ids = z.array(z.string()).parse(c.req.queries('id[]'));
const follows = await getFollowedPubkeys(pubkey);
const results = await Promise.all(ids.map(async (id) => {
const followLists = await store.query([{ kinds: [3], authors: follows, '#p': [id] }])
.then((events) => hydrateEvents({ events, store }));
const accounts = await Promise.all(
followLists.map((event) => event.author ? renderAccount(event.author) : accountFromPubkey(event.pubkey)),
);
return { id, accounts };
}));
return c.json(results);
};
export {
accountController,
accountLookupController,
@@ -409,6 +431,7 @@ export {
accountStatusesController,
blockController,
createAccountController,
familiarFollowersController,
favouritesController,
followController,
followersController,