diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/src/routes/guilds/#guild_id/bans.ts | 20 |
1 files changed, 12 insertions, 8 deletions
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) => { |