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 | 5a215b1af796de6464250b5cc445128b3307457a (patch) | |
tree | 3f37c125e3a0f17a4c76503ee78e550e68f399b8 | |
parent | [Fix] Invisible space username (#639) (diff) | |
download | server-5a215b1af796de6464250b5cc445128b3307457a.tar.xz |
Mutual Guilds (#637)
-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, |