diff options
author | Iratu <me@iratu.pro> | 2022-02-16 21:23:50 +0000 |
---|---|---|
committer | Erkin Alp Güney <erkinalp9035@gmail.com> | 2022-02-18 19:50:11 +0300 |
commit | 63fe1ef3b2d082d49ea1397629601e4f019a7801 (patch) | |
tree | d84f6e843147c7034fa742c68b7e950f54accdc7 /api/src/routes | |
parent | Merge pull request #608 from Featyre/master (diff) | |
download | server-63fe1ef3b2d082d49ea1397629601e4f019a7801.tar.xz |
Fix for Premium Since to show the 'Guild Boost' and store it correctly in the database
Diffstat (limited to 'api/src/routes')
-rw-r--r-- | api/src/routes/users/#id/profile.ts | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/api/src/routes/users/#id/profile.ts b/api/src/routes/users/#id/profile.ts index 9481451d..06be66ae 100644 --- a/api/src/routes/users/#id/profile.ts +++ b/api/src/routes/users/#id/profile.ts @@ -16,21 +16,29 @@ router.get("/", route({ test: { response: { body: "UserProfileResponse" } } }), const user = await User.getPublicUser(req.params.id, { relations: ["connected_accounts"] }); var mutual_guilds: object[] = []; - + var premium_guild_since; const requested_member = await Member.find( { id: req.params.id, }) const self_member = await Member.find( { id: req.user_id, }) for(const rmem of requested_member) { + if(rmem.premium_since) { + if(premium_guild_since){ + if(premium_guild_since > rmem.premium_since) { + premium_guild_since = rmem.premium_since; + } + } else { + premium_guild_since = rmem.premium_since; + } + } for(const smem of self_member) { if (smem.guild_id === rmem.guild_id) { mutual_guilds.push({id: rmem.guild_id, nick: rmem.nick}) } } } - res.json({ connected_accounts: user.connected_accounts, - premium_guild_since: null, // TODO + premium_guild_since: premium_guild_since, // TODO premium_since: null, // TODO mutual_guilds: mutual_guilds, // TODO {id: "", nick: null} when ?with_mutual_guilds=true user: { |