From b92a4285c993199a52cad30406a0d09f140e79d3 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Fri, 6 Sep 2024 10:12:19 +0100 Subject: [PATCH] Removed the user itself --- src/pages/api/users/list.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/api/users/list.ts b/src/pages/api/users/list.ts index b6d13ade..0a5273de 100644 --- a/src/pages/api/users/list.ts +++ b/src/pages/api/users/list.ts @@ -30,12 +30,12 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { const belongingGroups = await getGroupsForUser(undefined, req.session.user.id); const participants = uniq([...adminGroups.flatMap((x) => x.participants), ...belongingGroups.flat().flatMap((x) => x.participants)]); - return res.status(200).json(users.filter((x) => participants.includes(x.id))); + return res.status(200).json(users.filter((x) => participants.includes(x.id) && x.id !== req.session.user!.id)); } const adminGroups = await getGroupsForUser(req.session.user.id); const groups = await Promise.all(adminGroups.flatMap((x) => x.participants).map(async (x) => await getGroupsForUser(x))); const participants = uniq([...adminGroups.flatMap((x) => x.participants), ...groups.flat().flatMap((x) => x.participants)]); - res.status(200).json(users.filter((x) => participants.includes(x.id))); + res.status(200).json(users.filter((x) => participants.includes(x.id) && x.id !== req.session.user!.id)); }