summary refs log tree commit diff
path: root/src/api/routes/users/@me
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-06-13 01:10:59 +0200
committerRory& <root@rory.gay>2026-06-13 01:10:59 +0200
commit92f25c3a22249c65205dd61dfc8399989a010a0e (patch)
treec4a5403bd1b17aa7110da6a5512e3e1341fe7619 /src/api/routes/users/@me
parentBump npm package minors (diff)
downloadserver-ts-92f25c3a22249c65205dd61dfc8399989a010a0e.tar.xz
HACKHACK: Migrate to typeorm v1.0.0, still work to do in actually updating all the queries properly
Diffstat (limited to 'src/api/routes/users/@me')
-rw-r--r--src/api/routes/users/@me/index.ts4
-rw-r--r--src/api/routes/users/@me/relationships.ts14
2 files changed, 9 insertions, 9 deletions
diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts

index 1fda0afb6..ecb0b35cb 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts
@@ -37,7 +37,7 @@ router.get( async (req: Request, res: Response) => { res.json( await User.findOne({ - select: PrivateUserProjection, + select: Object.fromEntries(PrivateUserProjection.map((i) => [i, true])), //TODO: cleanup where: { id: req.user_id }, }), ); @@ -65,7 +65,7 @@ router.patch( const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: [...PrivateUserProjection, "data"], + select: Object.fromEntries([...PrivateUserProjection, "data"].map((i) => [i, true])), //TODO: cleanup }); // Populated on password change diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts
index d4d1eb1e8..6a6db5e4e 100644 --- a/src/api/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts
@@ -72,7 +72,7 @@ router.put( await User.findOneOrFail({ where: { id: req.params.user_id as string }, relations: { relationships: { to: true } }, - select: userProjection, + select: Object.fromEntries(userProjection.map((i) => [i, true])), // TODO: cleanup }), req.body.type ?? RelationshipType.friends, ), @@ -136,7 +136,7 @@ router.post( res, await User.findOneOrFail({ relations: { relationships: { to: true } }, - select: userProjection, + select: Object.fromEntries(userProjection.map((i) => [i, true])), // TODO: cleanup 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, @@ -165,12 +165,12 @@ router.delete( const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: userProjection, + select: Object.fromEntries(userProjection.map((i) => [i, true])), // TODO: cleanup relations: { relationships: true }, }); const friend = await User.findOneOrFail({ where: { id: user_id }, - select: userProjection, + select: Object.fromEntries(userProjection.map((i) => [i, true])), // TODO: cleanup relations: { relationships: true }, }); @@ -215,8 +215,6 @@ router.delete( }, ); -export default router; - async function updateRelationship(req: Request, res: Response, friend: User, type: RelationshipType) { const id = friend.id; if (id === req.user_id) throw new HTTPError("You can't add yourself as a friend"); @@ -224,7 +222,7 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ const user = await User.findOneOrFail({ where: { id: req.user_id }, relations: { relationships: { to: true } }, - select: userProjection, + select: Object.fromEntries(userProjection.map((i) => [i, true])), //TODO: cleanup }); let relationship = user.relationships.find((x) => x.to_id === id); @@ -316,3 +314,5 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ return res.sendStatus(204); } + +export default router;