Implement familiar followers
This commit is contained in:
parent
ca755b6d77
commit
622a2b2a4f
|
@ -13,6 +13,7 @@ import {
|
||||||
accountSearchController,
|
accountSearchController,
|
||||||
accountStatusesController,
|
accountStatusesController,
|
||||||
createAccountController,
|
createAccountController,
|
||||||
|
familiarFollowersController,
|
||||||
favouritesController,
|
favouritesController,
|
||||||
followController,
|
followController,
|
||||||
followersController,
|
followersController,
|
||||||
|
@ -156,6 +157,7 @@ app.patch('/api/v1/accounts/update_credentials', requireSigner, updateCredential
|
||||||
app.get('/api/v1/accounts/search', accountSearchController);
|
app.get('/api/v1/accounts/search', accountSearchController);
|
||||||
app.get('/api/v1/accounts/lookup', accountLookupController);
|
app.get('/api/v1/accounts/lookup', accountLookupController);
|
||||||
app.get('/api/v1/accounts/relationships', requireSigner, relationshipsController);
|
app.get('/api/v1/accounts/relationships', requireSigner, relationshipsController);
|
||||||
|
app.get('/api/v1/accounts/familiar_followers', requireSigner, familiarFollowersController);
|
||||||
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/block', requireSigner, blockController);
|
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/block', requireSigner, blockController);
|
||||||
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/unblock', requireSigner, unblockController);
|
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/unblock', requireSigner, unblockController);
|
||||||
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/mute', requireSigner, muteController);
|
app.post('/api/v1/accounts/:pubkey{[0-9a-f]{64}}/mute', requireSigner, muteController);
|
||||||
|
|
|
@ -402,6 +402,28 @@ const favouritesController: AppController = async (c) => {
|
||||||
return paginated(c, events1, statuses);
|
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 {
|
export {
|
||||||
accountController,
|
accountController,
|
||||||
accountLookupController,
|
accountLookupController,
|
||||||
|
@ -409,6 +431,7 @@ export {
|
||||||
accountStatusesController,
|
accountStatusesController,
|
||||||
blockController,
|
blockController,
|
||||||
createAccountController,
|
createAccountController,
|
||||||
|
familiarFollowersController,
|
||||||
favouritesController,
|
favouritesController,
|
||||||
followController,
|
followController,
|
||||||
followersController,
|
followersController,
|
||||||
|
|
Loading…
Reference in New Issue