diff options
Diffstat (limited to 'internal/api/client/admin')
-rw-r--r-- | internal/api/client/admin/emojicreate.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/api/client/admin/emojicreate.go b/internal/api/client/admin/emojicreate.go index 39ebd5adf..eef49b2c7 100644 --- a/internal/api/client/admin/emojicreate.go +++ b/internal/api/client/admin/emojicreate.go @@ -26,6 +26,7 @@ import ( "github.com/gin-gonic/gin" "github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api/model" + "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/validate" @@ -56,7 +57,9 @@ import ( // required: true // - name: image // in: formData -// description: A png or gif image of the emoji. Animated pngs work too! +// description: |- +// A png or gif image of the emoji. Animated pngs work too! +// To ensure compatibility with other fedi implementations, emoji size limit is 50kb by default. // type: file // required: true // @@ -126,5 +129,10 @@ func validateCreateEmoji(form *model.EmojiCreateRequest) error { return errors.New("no emoji given") } + maxSize := config.GetMediaEmojiLocalMaxSize() + if form.Image.Size > int64(maxSize) { + return fmt.Errorf("emoji image too large: image is %dKB but size limit for custom emojis is %dKB", form.Image.Size/1024, maxSize/1024) + } + return validate.EmojiShortcode(form.Shortcode) } |