Removed the user itself
This commit is contained in:
@@ -30,12 +30,12 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
const belongingGroups = await getGroupsForUser(undefined, req.session.user.id);
|
const belongingGroups = await getGroupsForUser(undefined, req.session.user.id);
|
||||||
|
|
||||||
const participants = uniq([...adminGroups.flatMap((x) => x.participants), ...belongingGroups.flat().flatMap((x) => x.participants)]);
|
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 adminGroups = await getGroupsForUser(req.session.user.id);
|
||||||
const groups = await Promise.all(adminGroups.flatMap((x) => x.participants).map(async (x) => await getGroupsForUser(x)));
|
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)]);
|
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));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user