summaryrefslogtreecommitdiff
path: root/internal/api/client/admin/emojicreate.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-02-12 18:27:58 +0000
committerLibravatar GitHub <noreply@github.com>2022-02-12 18:27:58 +0000
commit31935ee206107f077878d3cdb6a26b82436b6893 (patch)
tree2d522bf98013dc5a4539133561b645fd7457eb06 /internal/api/client/admin/emojicreate.go
parent[chore] Add nightly mirror to Codeberg.org (#392) (diff)
parentGo mod tidy (diff)
downloadgotosocial-31935ee206107f077878d3cdb6a26b82436b6893.tar.xz
Merge pull request #361 from superseriousbusiness/media_refactorv0.2.0
Refactor media handler to allow async media resolution
Diffstat (limited to 'internal/api/client/admin/emojicreate.go')
-rw-r--r--internal/api/client/admin/emojicreate.go20
1 files changed, 8 insertions, 12 deletions
diff --git a/internal/api/client/admin/emojicreate.go b/internal/api/client/admin/emojicreate.go
index 617add413..ef42d0a13 100644
--- a/internal/api/client/admin/emojicreate.go
+++ b/internal/api/client/admin/emojicreate.go
@@ -27,12 +27,11 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/api/model"
- "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/validate"
)
-// emojiCreateRequest swagger:operation POST /api/v1/admin/custom_emojis emojiCreate
+// EmojiCreatePOSTHandler swagger:operation POST /api/v1/admin/custom_emojis emojiCreate
//
// Upload and create a new instance emoji.
//
@@ -74,7 +73,9 @@ import (
// description: forbidden
// '400':
// description: bad request
-func (m *Module) emojiCreatePOSTHandler(c *gin.Context) {
+// '409':
+// description: conflict -- domain/shortcode combo for emoji already exists
+func (m *Module) EmojiCreatePOSTHandler(c *gin.Context) {
l := logrus.WithFields(logrus.Fields{
"func": "emojiCreatePOSTHandler",
"request_uri": c.Request.RequestURI,
@@ -117,10 +118,10 @@ func (m *Module) emojiCreatePOSTHandler(c *gin.Context) {
return
}
- apiEmoji, err := m.processor.AdminEmojiCreate(c.Request.Context(), authed, form)
- if err != nil {
- l.Debugf("error creating emoji: %s", err)
- c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+ apiEmoji, errWithCode := m.processor.AdminEmojiCreate(c.Request.Context(), authed, form)
+ if errWithCode != nil {
+ l.Debugf("error creating emoji: %s", errWithCode.Error())
+ c.JSON(errWithCode.Code(), gin.H{"error": errWithCode.Safe()})
return
}
@@ -133,10 +134,5 @@ func validateCreateEmoji(form *model.EmojiCreateRequest) error {
return errors.New("no emoji given")
}
- // a very superficial check to see if the media size limit is exceeded
- if form.Image.Size > media.EmojiMaxBytes {
- return fmt.Errorf("file size limit exceeded: limit is %d bytes but emoji was %d bytes", media.EmojiMaxBytes, form.Image.Size)
- }
-
return validate.EmojiShortcode(form.Shortcode)
}