From 268f252e0d517f2693b30d03fb8a68a0764a43bc Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 12 Sep 2022 13:03:23 +0200 Subject: [feature] Fetch + display custom emoji in statuses from remote instances (#807) * start implementing remote emoji fetcher * update status where pk * aaa * tidy up a little * check size limits for emojis * thank you linter, i love you <3 * update swagger docs * add emoji dereference test * make emoji max sizes configurable * normalize db.ErrAlreadyExists --- internal/api/client/admin/emojicreate.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'internal/api/client/admin/emojicreate.go') 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) } -- cgit v1.2.3