diff options
author | 2022-11-14 23:47:27 +0100 | |
---|---|---|
committer | 2022-11-14 22:47:27 +0000 | |
commit | 4cd00d546c495b085487d11f2fe2c4928600dc10 (patch) | |
tree | 6605424baafddf020a4a6e0a0ddcde9293c1cb56 /internal/validate/formvalidation.go | |
parent | [chore] Remove unused `admin account suspend` action (#1047) (diff) | |
download | gotosocial-4cd00d546c495b085487d11f2fe2c4928600dc10.tar.xz |
[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
Diffstat (limited to 'internal/validate/formvalidation.go')
-rw-r--r-- | internal/validate/formvalidation.go | 9 |
1 files changed, 9 insertions, 0 deletions
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 { |