diff options
Diffstat (limited to 'api/src/routes/users/#id/profile.ts')
-rw-r--r-- | api/src/routes/users/#id/profile.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/api/src/routes/users/#id/profile.ts b/api/src/routes/users/#id/profile.ts index 9481451d..4dbb84cf 100644 --- a/api/src/routes/users/#id/profile.ts +++ b/api/src/routes/users/#id/profile.ts @@ -16,22 +16,30 @@ 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_since: null, // TODO + premium_guild_since: premium_guild_since, // TODO + premium_since: user.premium_since, // TODO mutual_guilds: mutual_guilds, // TODO {id: "", nick: null} when ?with_mutual_guilds=true user: { username: user.username, |