From 4cd00d546c495b085487d11f2fe2c4928600dc10 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 14 Nov 2022 23:47:27 +0100 Subject: [feature] Allow newly uploaded emojis to be placed in categories (#939) * [feature] Add emoji categories GET Serialize emojis in appropriate categories; make it possible to get categories via the admin API * [feature] Create (or use existing) category for new emoji uploads * fix lint issue * update misleading line in swagger docs --- internal/validate/formvalidation.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'internal/validate/formvalidation.go') diff --git a/internal/validate/formvalidation.go b/internal/validate/formvalidation.go index ccf5e6504..5d6e3142c 100644 --- a/internal/validate/formvalidation.go +++ b/internal/validate/formvalidation.go @@ -42,6 +42,7 @@ const ( maximumSiteTermsLength = 5000 maximumUsernameLength = 64 maximumCustomCSSLength = 5000 + maximumEmojiCategoryLength = 64 ) // NewPassword returns an error if the given password is not sufficiently strong, or nil if it's ok. @@ -182,6 +183,14 @@ func EmojiShortcode(shortcode string) error { return nil } +// EmojiCategory validates the length of the given category string. +func EmojiCategory(category string) error { + if length := len(category); length > maximumEmojiCategoryLength { + return fmt.Errorf("emoji category %s did not pass validation, must be less than %d characters, but provided value was %d characters", category, maximumEmojiCategoryLength, length) + } + return nil +} + // SiteTitle ensures that the given site title is within spec. func SiteTitle(siteTitle string) error { if length := len([]rune(siteTitle)); length > maximumSiteTitleLength { -- cgit v1.2.3