summaryrefslogtreecommitdiff
path: root/internal/processing/admin/createemoji.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-11-14 23:47:27 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-14 22:47:27 +0000
commit4cd00d546c495b085487d11f2fe2c4928600dc10 (patch)
tree6605424baafddf020a4a6e0a0ddcde9293c1cb56 /internal/processing/admin/createemoji.go
parent[chore] Remove unused `admin account suspend` action (#1047) (diff)
downloadgotosocial-4cd00d546c495b085487d11f2fe2c4928600dc10.tar.xz
[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
Diffstat (limited to 'internal/processing/admin/createemoji.go')
-rw-r--r--internal/processing/admin/createemoji.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/internal/processing/admin/createemoji.go b/internal/processing/admin/createemoji.go
index a315e144e..db51d52b6 100644
--- a/internal/processing/admin/createemoji.go
+++ b/internal/processing/admin/createemoji.go
@@ -28,6 +28,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id"
+ "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/uris"
)
@@ -57,7 +58,19 @@ func (p *processor) EmojiCreate(ctx context.Context, account *gtsmodel.Account,
return f, form.Image.Size, err
}
- processingEmoji, err := p.mediaManager.ProcessEmoji(ctx, data, nil, form.Shortcode, emojiID, emojiURI, nil, false)
+ var ai *media.AdditionalEmojiInfo
+ if form.CategoryName != "" {
+ category, err := p.GetOrCreateEmojiCategory(ctx, form.CategoryName)
+ if err != nil {
+ return nil, gtserror.NewErrorInternalError(fmt.Errorf("error putting id in category: %s", err), "error putting id in category")
+ }
+
+ ai = &media.AdditionalEmojiInfo{
+ CategoryID: &category.ID,
+ }
+ }
+
+ processingEmoji, err := p.mediaManager.ProcessEmoji(ctx, data, nil, form.Shortcode, emojiID, emojiURI, ai, false)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error processing emoji: %s", err), "error processing emoji")
}