From c097fce8417ea9af344203e5d27430cdea5e110f Mon Sep 17 00:00:00 2001 From: RealMANI <96433859+ImAaronFR@users.noreply.github.com> Date: Tue, 8 Mar 2022 18:35:19 +0330 Subject: Fix bans list (#674) * Fix bans list - Bans list should load properly now * Updated Removed await Removed unnecessary foreach * Update ban.ts await --- api/src/routes/guilds/#guild_id/bans.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'api') diff --git a/api/src/routes/guilds/#guild_id/bans.ts b/api/src/routes/guilds/#guild_id/bans.ts index 7ccf34d7..99adf5ae 100644 --- a/api/src/routes/guilds/#guild_id/bans.ts +++ b/api/src/routes/guilds/#guild_id/bans.ts @@ -33,17 +33,21 @@ router.get("/", route({ permission: "BAN_MEMBERS" }), async (req: Request, res: const { guild_id } = req.params; let bans = await Ban.find({ guild_id: guild_id }); - - /* Filter secret from database registry.*/ - - bans.filter(ban => ban.user_id !== ban.executor_id); + // pretend self-bans don't exist to prevent victim chasing + bans.filter(ban => ban.user_id !== ban.executor_id); - bans.forEach((registry: BanRegistrySchema) => { - delete registry.ip; - }); + /* Create an separate array to modify and return */ + + var bans_array: object[] = []; + + for (const ban of bans) { + const banned_user = await User.getPublicUser(ban.user_id); + var ban_object = {user: {id: banned_user.id, username: banned_user.username, avatar: banned_user.avatar, discriminator: banned_user.discriminator, public_flags: banned_user.public_flags}, reason: ban.reason}; + bans_array.push(ban_object) + } - return res.json(bans); + return res.json(bans_array); }); router.get("/:user", route({ permission: "BAN_MEMBERS" }), async (req: Request, res: Response) => { -- cgit 1.4.1