diff options
author | RealMANI <96433859+ImAaronFR@users.noreply.github.com> | 2022-02-16 11:15:54 +0330 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 10:45:54 +0300 |
commit | 76d5d83dc793e0785ffd8143f1c44332068dfd39 (patch) | |
tree | 834936b9a763080f6f82f96302af56e15e620a0d /api/src/routes/users | |
parent | [Fix] Invisible space username (#639) (diff) | |
download | server-76d5d83dc793e0785ffd8143f1c44332068dfd39.tar.xz |
Mutual Guilds (#637)
Diffstat (limited to 'api/src/routes/users')
-rw-r--r-- | api/src/routes/users/#id/profile.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/api/src/routes/users/#id/profile.ts b/api/src/routes/users/#id/profile.ts index 15457547..9481451d 100644 --- a/api/src/routes/users/#id/profile.ts +++ b/api/src/routes/users/#id/profile.ts @@ -1,5 +1,5 @@ import { Router, Request, Response } from "express"; -import { PublicConnectedAccount, PublicUser, User, UserPublic } from "@fosscord/util"; +import { PublicConnectedAccount, PublicUser, User, UserPublic, Member } from "@fosscord/util"; import { route } from "@fosscord/api"; const router: Router = Router(); @@ -15,11 +15,24 @@ router.get("/", route({ test: { response: { body: "UserProfileResponse" } } }), if (req.params.id === "@me") req.params.id = req.user_id; const user = await User.getPublicUser(req.params.id, { relations: ["connected_accounts"] }); + var mutual_guilds: object[] = []; + + 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) { + 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 - mutual_guilds: [], // TODO {id: "", nick: null} when ?with_mutual_guilds=true + mutual_guilds: mutual_guilds, // TODO {id: "", nick: null} when ?with_mutual_guilds=true user: { username: user.username, discriminator: user.discriminator, |