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 | 58d58928ec6a6d8cc0bb510f5ca348a3b834b3fe (patch) | |
tree | 3b32b1f402d3650d8eb866954045ee4b44d1b8c1 /api/src | |
parent | Merge pull request #608 from Featyre/master (diff) | |
download | server-58d58928ec6a6d8cc0bb510f5ca348a3b834b3fe.tar.xz |
Fix for Premium Since to show the 'Guild Boost' and store it correctly in the database
Diffstat (limited to 'api/src')
-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: { |