diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-06-28 15:54:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-28 15:54:10 +0200 |
commit | e64e6a03dd1e0978fee48f0596dcfbc7fd29958f (patch) | |
tree | d3a3da3ebed0fc4b942993bab88240f360903686 /app/serializers | |
parent | 072158ee973f8e09a0abd34a825d9bce038a5d68 (diff) |
Add categories for custom emojis (#11196)
Fix #7940
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/rest/custom_emoji_serializer.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/serializers/rest/custom_emoji_serializer.rb b/app/serializers/rest/custom_emoji_serializer.rb index 65686a866..aff58e4d9 100644 --- a/app/serializers/rest/custom_emoji_serializer.rb +++ b/app/serializers/rest/custom_emoji_serializer.rb @@ -5,6 +5,8 @@ class REST::CustomEmojiSerializer < ActiveModel::Serializer attributes :shortcode, :url, :static_url, :visible_in_picker + attribute :category, if: :category_loaded? + def url full_asset_url(object.image.url) end @@ -12,4 +14,12 @@ class REST::CustomEmojiSerializer < ActiveModel::Serializer def static_url full_asset_url(object.image.url(:static)) end + + def category + object.category.name + end + + def category_loaded? + object.association(:category).loaded? && object.category.present? + end end |