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:
parent
39a3eee45d
commit
c097fce841
@ -34,16 +34,20 @@ router.get("/", route({ permission: "BAN_MEMBERS" }), async (req: Request, res:
|
||||
|
||||
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 */
|
||||
|
||||
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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user