1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-06 10:52:31 +01:00

Fix bans list (#674)

* Fix bans list

- Bans list should load properly now

* Updated

Removed await
Removed unnecessary foreach

* Update ban.ts

await
This commit is contained in:
RealMANI 2022-03-08 18:35:19 +03:30 committed by GitHub
parent 39a3eee45d
commit c097fce841

View File

@ -33,17 +33,21 @@ router.get("/", route({ permission: "BAN_MEMBERS" }), async (req: Request, res:
const { guild_id } = req.params; const { guild_id } = req.params;
let bans = await Ban.find({ guild_id: guild_id }); 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 // pretend self-bans don't exist to prevent victim chasing
bans.filter(ban => ban.user_id !== ban.executor_id);
bans.forEach((registry: BanRegistrySchema) => { /* Create an separate array to modify and return */
delete registry.ip;
});
return res.json(bans); 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_array);
}); });
router.get("/:user", route({ permission: "BAN_MEMBERS" }), async (req: Request, res: Response) => { router.get("/:user", route({ permission: "BAN_MEMBERS" }), async (req: Request, res: Response) => {