about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-06-28 22:35:54 +0200
committerGitHub <noreply@github.com>2019-06-28 22:35:54 +0200
commit98c2d2aa46c2725b360907cf5537338ac6d052ed (patch)
tree4b3301453fc3f8bcfe412a5e1bb967ec5c3414c6 /app/serializers
parentf7c0e326ab11a597b17a22dd8889f0690d7ffd73 (diff)
parent662252c8f77e8dd8fd015bc6ece0943f068b1710 (diff)
Merge pull request #1146 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/rest/custom_emoji_serializer.rb10
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