Try to make relationshipsController reflect following

This commit is contained in:
Alex Gleason 2023-05-03 21:56:22 -05:00
parent 192ee7f76d
commit 9539eb5055
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 9 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import { type AppController } from '@/app.ts';
import { nip05, z } from '@/deps.ts';
import { getAuthor, getFilter } from '@/client.ts';
import { getAuthor, getFilter, getFollows } from '@/client.ts';
import { toAccount, toStatus } from '@/transmute.ts';
import { bech32ToPubkey, eventDateComparator } from '@/utils.ts';
@ -58,16 +58,19 @@ const accountSearchController: AppController = async (c) => {
return c.json([]);
};
const relationshipsController: AppController = (c) => {
const ids = c.req.queries('id[]');
const relationshipsController: AppController = async (c) => {
const pubkey = c.get('pubkey')!;
const ids = z.array(z.string()).safeParse(c.req.queries('id[]'));
if (!ids) {
if (!ids.success) {
return c.json({ error: 'Missing `id[]` query parameters.' }, 422);
}
const result = ids.map((id) => ({
const follows = await getFollows(pubkey);
const result = ids.data.map((id) => ({
id,
following: false,
following: !!follows?.tags.find((tag) => tag[0] === 'p' && ids.data.includes(tag[1])),
showing_reblogs: false,
notifying: false,
followed_by: false,