summary refs log tree commit diff
diff options
context:
space:
mode:
authorRealMANI <96433859+ImAaronFR@users.noreply.github.com>2022-03-08 18:35:19 +0330
committerGitHub <noreply@github.com>2022-03-08 18:05:19 +0300
commitc097fce8417ea9af344203e5d27430cdea5e110f (patch)
treec873cbc915b2b64ffd3e7de6e7d45854787cf4e1
parentRevert "Type change" (diff)
downloadserver-c097fce8417ea9af344203e5d27430cdea5e110f.tar.xz
Fix bans list (#674)
* Fix bans list

- Bans list should load properly now

* Updated

Removed await
Removed unnecessary foreach

* Update ban.ts

await
-rw-r--r--api/src/routes/guilds/#guild_id/bans.ts20
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) => {