summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-08-30 06:30:53 +0200
committerRory& <root@rory.gay>2026-08-30 06:30:53 +0200
commit9c5eb62be7b51bd56cf2ca82e18f94cc3ed5cbdc (patch)
tree03138e5af209a7f889baef6c31335582f6bf5a12
parentFix a typo (diff)
parentfix: Add character limit for pronouns (diff)
downloadserver-ts-9c5eb62be7b51bd56cf2ca82e18f94cc3ed5cbdc.tar.xz
Merge remote-tracking branch 'Vespe-r/fix/pronouns_length_limit'
-rw-r--r--assets/openapi.json5
-rw-r--r--assets/schemas.json5
-rw-r--r--src/api/routes/users/#user_id/profile.ts12
-rw-r--r--src/util/config/types/subconfigurations/limits/UserLimits.ts1
4 files changed, 23 insertions, 0 deletions
diff --git a/assets/openapi.json b/assets/openapi.json

index b147fc36a..f51ef3805 100644 --- a/assets/openapi.json +++ b/assets/openapi.json
@@ -14975,12 +14975,17 @@ "maxBio": { "type": "integer", "default": 190 + }, + "maxPronouns": { + "type": "integer", + "default": 40 } }, "required": [ "maxBio", "maxFriends", "maxGuilds", + "maxPronouns", "maxUsername" ] }, diff --git a/assets/schemas.json b/assets/schemas.json
index fa1337109..40474e02c 100644 --- a/assets/schemas.json +++ b/assets/schemas.json
@@ -15972,6 +15972,10 @@ "maxBio": { "type": "integer", "default": 190 + }, + "maxPronouns": { + "type": "integer", + "default": 40 } }, "additionalProperties": false, @@ -15979,6 +15983,7 @@ "maxBio", "maxFriends", "maxGuilds", + "maxPronouns", "maxUsername" ], "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/src/api/routes/users/#user_id/profile.ts b/src/api/routes/users/#user_id/profile.ts
index 1db2a63da..ef7ff0e8c 100644 --- a/src/api/routes/users/#user_id/profile.ts +++ b/src/api/routes/users/#user_id/profile.ts
@@ -187,6 +187,18 @@ router.patch("/", route({ requestBody: "UserProfileModifySchema" }), async (req: } } + if (body.pronouns) { + const { maxPronouns } = Config.get().limits.user; + if (body.pronouns.length > maxPronouns) { + throw FieldErrors({ + pronouns: { + code: "PRONOUNS_INVALID", + message: `Pronouns must be less than ${maxPronouns} in length`, + }, + }); + } + } + user.assign(body); await user.save(); diff --git a/src/util/config/types/subconfigurations/limits/UserLimits.ts b/src/util/config/types/subconfigurations/limits/UserLimits.ts
index cbe686d14..8a9647cc6 100644 --- a/src/util/config/types/subconfigurations/limits/UserLimits.ts +++ b/src/util/config/types/subconfigurations/limits/UserLimits.ts
@@ -21,4 +21,5 @@ export class UserLimits { maxUsername: number = 32; maxFriends: number = 5000; maxBio: number = 190; + maxPronouns: number = 40; }