2017-09-23 08:57:23 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
|
|
|
include RoutingHelper
|
|
|
|
|
2023-09-26 18:25:01 +09:00
|
|
|
# Please update `app/javascript/mastodon/api_types/custom_emoji.ts` when making changes to the attributes
|
|
|
|
|
2017-10-27 23:11:30 +09:00
|
|
|
attributes :shortcode, :url, :static_url, :visible_in_picker
|
2017-09-23 08:57:23 +09:00
|
|
|
|
2019-06-28 22:54:10 +09:00
|
|
|
attribute :category, if: :category_loaded?
|
|
|
|
|
2017-09-23 08:57:23 +09:00
|
|
|
def url
|
|
|
|
full_asset_url(object.image.url)
|
|
|
|
end
|
2017-10-06 06:41:47 +09:00
|
|
|
|
|
|
|
def static_url
|
|
|
|
full_asset_url(object.image.url(:static))
|
|
|
|
end
|
2019-06-28 22:54:10 +09:00
|
|
|
|
|
|
|
def category
|
|
|
|
object.category.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def category_loaded?
|
|
|
|
object.association(:category).loaded? && object.category.present?
|
|
|
|
end
|
2017-09-23 08:57:23 +09:00
|
|
|
end
|