From 44bd12e7a80858f8364016d0f013fc1b7ca5943b Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Sun, 17 Jul 2022 21:39:47 +0100 Subject: [PATCH] fix: allow 0 length about-mes --- client/src/app/pages/dashboard/users/UserPage.tsx | 2 +- client/src/app/pages/dashboard/users/UserSettingsPage.tsx | 1 + common/src/lib/schemas.ts | 2 +- server/src/server/router/api/v1/users/_userID/router.ts | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/app/pages/dashboard/users/UserPage.tsx b/client/src/app/pages/dashboard/users/UserPage.tsx index 001f6011a..6d449d9d6 100644 --- a/client/src/app/pages/dashboard/users/UserPage.tsx +++ b/client/src/app/pages/dashboard/users/UserPage.tsx @@ -34,7 +34,7 @@ function AboutMeCard({ reqUser }: Props) { headers: { "Content-Type": "application/json", }, - body: JSON.stringify({ about: content }), + body: JSON.stringify({ about: content.length === 0 ? null : content }), }, true, true diff --git a/client/src/app/pages/dashboard/users/UserSettingsPage.tsx b/client/src/app/pages/dashboard/users/UserSettingsPage.tsx index f24ce3e6a..9906c1b46 100644 --- a/client/src/app/pages/dashboard/users/UserSettingsPage.tsx +++ b/client/src/app/pages/dashboard/users/UserSettingsPage.tsx @@ -336,6 +336,7 @@ function SocialMediaForm({ reqUser }: { reqUser: PublicUserDocument }) { }, onSubmit: async (values) => { const valuesClone: Record = {}; + for (const v in values) { const vx = v as keyof typeof values; valuesClone[vx] = values[vx] || null; diff --git a/common/src/lib/schemas.ts b/common/src/lib/schemas.ts index 3974f64fd..9f2fe8780 100644 --- a/common/src/lib/schemas.ts +++ b/common/src/lib/schemas.ts @@ -986,7 +986,7 @@ const PRE_SCHEMAS = { twitch: "*?string", }, joinDate: p.isPositiveInteger, - about: p.isBoundedString(0, 4000), + about: p.isBoundedString(0, 2000), status: p.nullable(p.isBoundedString(3, 140)), customPfpLocation: "?string", customBannerLocation: "?string", diff --git a/server/src/server/router/api/v1/users/_userID/router.ts b/server/src/server/router/api/v1/users/_userID/router.ts index 53042bab3..7a5cce78b 100644 --- a/server/src/server/router/api/v1/users/_userID/router.ts +++ b/server/src/server/router/api/v1/users/_userID/router.ts @@ -77,7 +77,7 @@ router.patch( "/", RequireSelfRequestFromUser, prValidate({ - about: p.optional(p.isBoundedString(3, 2000)), + about: p.optional(p.isBoundedString(0, 2000)), status: optNullFluffStrField, discord: optNullFluffStrField, twitter: optNullFluffStrField,