summaryrefslogtreecommitdiff
path: root/internal/api/client/admin/emojicreate.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-09-12 13:03:23 +0200
committerLibravatar GitHub <noreply@github.com>2022-09-12 13:03:23 +0200
commit268f252e0d517f2693b30d03fb8a68a0764a43bc (patch)
tree95920c06bcdfc0ca11486aa08a547d85ca35f8ce /internal/api/client/admin/emojicreate.go
parent[docs] unbreak standard css (#818) (diff)
downloadgotosocial-268f252e0d517f2693b30d03fb8a68a0764a43bc.tar.xz
[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
Diffstat (limited to 'internal/api/client/admin/emojicreate.go')
-rw-r--r--internal/api/client/admin/emojicreate.go10
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)
}