diff --git a/api/src/routes/users/@me/relationships.ts b/api/src/routes/users/@me/relationships.ts
index 58d2e481..1d72f11a 100644
--- a/api/src/routes/users/@me/relationships.ts
+++ b/api/src/routes/users/@me/relationships.ts
@@ -18,9 +18,19 @@ const router = Router();
const userProjection: (keyof User)[] = ["relationships", ...PublicUserProjection];
router.get("/", route({}), async (req: Request, res: Response) => {
- const user = await User.findOneOrFail({ where: { id: req.user_id }, relations: ["relationships"] });
+ const user = await User.findOneOrFail({ where: { id: req.user_id }, relations: ["relationships", "relationships.to"] });
+
+ //TODO DTO
+ const related_users = user.relationships.map(r => {
+ return {
+ id: r.to.id,
+ type: r.type,
+ nickname: null,
+ user: r.to.toPublicUser(),
+ }
+ })
- return res.json(user.relationships);
+ return res.json(related_users);
});
export interface RelationshipPutSchema {
@@ -48,7 +58,10 @@ router.post("/", route({ body: "RelationshipPostSchema" }), async (req: Request,
await User.findOneOrFail({
relations: ["relationships", "relationships.to"],
select: userProjection,
- where: req.body as { discriminator: string; username: string }
+ where: {
+ discriminator: String(req.body.discriminator,).padStart(4, '0'), //Discord send the discriminator as integer, we need to add leading zeroes
+ username: req.body.username
+ }
}),
req.body.type
);
|