mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user