From b7d359c3cdb25ccb88db6bb370ef79bc713dc4e2 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Mon, 29 Dec 2025 11:00:18 -0600 Subject: [PATCH] Fix profile API It should no longer send a random user(Emma/Rory) and should now just send the correct user. --- src/api/routes/users/#user_id/profile.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/api/routes/users/#user_id/profile.ts b/src/api/routes/users/#user_id/profile.ts index e4d4d749e..c4a7a2efb 100644 --- a/src/api/routes/users/#user_id/profile.ts +++ b/src/api/routes/users/#user_id/profile.ts @@ -28,10 +28,11 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), if (req.params.user_id === "@me") req.params.user_id = req.user_id; const { guild_id, with_mutual_guilds, with_mutual_friends, with_mutual_friends_count } = req.query; + const { user_id } = req.params; const user = await User.findOneOrFail({ where: { - id: req.params.id, + id: user_id, }, relations: { connected_accounts: true }, }); @@ -41,10 +42,10 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), if (with_mutual_guilds == "true") { const requested_member = await Member.find({ - where: { id: req.params.user_id }, + where: { id: user_id }, }); const self_member = await Member.find({ - where: { id: req.user_id }, + where: { id: user_id }, }); for (const rmem of requested_member) { @@ -71,7 +72,7 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), const guild_member = guild_id && typeof guild_id == "string" ? await Member.findOneOrFail({ - where: { id: req.params.user_id, guild_id: guild_id }, + where: { id: user_id, guild_id: guild_id }, relations: { roles: true }, }) : undefined; @@ -99,8 +100,8 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), let mutual_friends_count = 0; if (with_mutual_friends == "true" || with_mutual_friends_count == "true") { - const relationshipsSelf = await Relationship.find({ where: { from_id: req.user_id, type: RelationshipType.friends } }); - const relationshipsUser = await Relationship.find({ where: { from_id: req.params.user_id, type: RelationshipType.friends } }); + const relationshipsSelf = await Relationship.find({ where: { from_id: user_id, type: RelationshipType.friends } }); + const relationshipsUser = await Relationship.find({ where: { from_id: user_id, type: RelationshipType.friends } }); const relationshipsIntersection = relationshipsSelf.filter((r1) => relationshipsUser.some((r2) => r2.to_id === r1.to_id)); if (with_mutual_friends_count) mutual_friends_count = relationshipsIntersection.length; if (with_mutual_friends) {