summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltofrontend.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/typeutils/internaltofrontend.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/typeutils/internaltofrontend.go')
-rw-r--r--internal/typeutils/internaltofrontend.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go
index b2e2279bb..ac834f78d 100644
--- a/internal/typeutils/internaltofrontend.go
+++ b/internal/typeutils/internaltofrontend.go
@@ -356,12 +356,24 @@ func (c *converter) MentionToAPIMention(ctx context.Context, m *gtsmodel.Mention
}
func (c *converter) EmojiToAPIEmoji(ctx context.Context, e *gtsmodel.Emoji) (model.Emoji, error) {
+ var category string
+ if e.CategoryID != "" {
+ if e.Category == nil {
+ var err error
+ e.Category, err = c.db.GetEmojiCategory(ctx, e.CategoryID)
+ if err != nil {
+ return model.Emoji{}, err
+ }
+ }
+ category = e.Category.Name
+ }
+
return model.Emoji{
Shortcode: e.Shortcode,
URL: e.ImageURL,
StaticURL: e.ImageStaticURL,
VisibleInPicker: *e.VisibleInPicker,
- Category: e.CategoryID,
+ Category: category,
}, nil
}
@@ -383,6 +395,13 @@ func (c *converter) EmojiToAdminAPIEmoji(ctx context.Context, e *gtsmodel.Emoji)
}, nil
}
+func (c *converter) EmojiCategoryToAPIEmojiCategory(ctx context.Context, category *gtsmodel.EmojiCategory) (*model.EmojiCategory, error) {
+ return &model.EmojiCategory{
+ ID: category.ID,
+ Name: category.Name,
+ }, nil
+}
+
func (c *converter) TagToAPITag(ctx context.Context, t *gtsmodel.Tag) (model.Tag, error) {
return model.Tag{
Name: t.Name,