[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
This commit is contained in:
tobi
2022-11-14 23:47:27 +01:00
committed by GitHub
parent 8c20ccd9a8
commit 4cd00d546c
31 changed files with 916 additions and 52 deletions

View File

@ -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 {