summary refs log tree commit diff
path: root/src/api/routes/users/@me
diff options
context:
space:
mode:
authorPuyodead1 <puyodead@protonmail.com>2023-05-05 11:09:05 -0400
committerPuyodead1 <puyodead@protonmail.com>2023-12-23 16:30:58 -0500
commit9f4f7cac6512330481ea3e2de0633fc893788c33 (patch)
tree54ac0220deba5a54c86d1a1b3b2a9369d926567b /src/api/routes/users/@me
parentupdate schemas.json and openapi.json (diff)
downloadserver-ts-9f4f7cac6512330481ea3e2de0633fc893788c33.tar.xz
initial pomelo implementation
Diffstat (limited to 'src/api/routes/users/@me')
-rw-r--r--src/api/routes/users/@me/index.ts2
-rw-r--r--src/api/routes/users/@me/relationships.ts21
2 files changed, 16 insertions, 7 deletions
diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts

index ad11a428..1d209542 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts
@@ -140,6 +140,7 @@ router.patch( newToken = (await generateToken(user.id)) as string; } + // TODO: pomelo: disallow if pomelo is enabled if (body.username) { const check_username = body?.username?.replace(/\s/g, ""); if (!check_username) { @@ -162,6 +163,7 @@ router.patch( } } + // TODO: pomelo: disallow if pomelo is enabled if (body.discriminator) { if ( await User.findOne({ diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts
index bce0a654..08342602 100644 --- a/src/api/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts
@@ -114,19 +114,26 @@ router.post( }, }), async (req: Request, res: Response) => { + const { pomeloEnabled } = Config.get().general; + const where = pomeloEnabled + ? { + // TODO: pomelo: should we use username or add global_name property to the request? + global_name: req.body.username, + } + : { + discriminator: String(req.body.discriminator).padStart( + 4, + "0", + ), //Discord send the discriminator as integer, we need to add leading zeroes + username: req.body.username, + }; return await updateRelationship( req, res, await User.findOneOrFail({ relations: ["relationships", "relationships.to"], select: userProjection, - 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, - }, + where, }), req.body.type, );