1
0

custom_emoji_serializer.rb 609 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. class REST::CustomEmojiSerializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. # Please update `app/javascript/mastodon/api_types/custom_emoji.ts` when making changes to the attributes
  5. attributes :shortcode, :url, :static_url, :visible_in_picker
  6. attribute :category, if: :category_loaded?
  7. def url
  8. full_asset_url(object.image.url)
  9. end
  10. def static_url
  11. full_asset_url(object.image.url(:static))
  12. end
  13. def category
  14. object.category.name
  15. end
  16. def category_loaded?
  17. object.association(:category).loaded? && object.category.present?
  18. end
  19. end