Add emoji_reactioned_by_slim api (not work)

This commit is contained in:
KMY 2023-02-27 08:45:11 +09:00
parent a1485f242d
commit 9ad51e001e
8 changed files with 98 additions and 3 deletions

View file

@ -0,0 +1,27 @@
# frozen_string_literal: true
class REST::EmojiReactedBySlimReactionSerializer < ActiveModel::Serializer
include RoutingHelper
attributes :name
attribute :url, if: :custom_emoji?
attribute :static_url, if: :custom_emoji?
attribute :domain, if: :custom_emoji?
def url
full_asset_url(object.custom_emoji.image.url)
end
def static_url
full_asset_url(object.custom_emoji.image.url(:static))
end
def domain
object.custom_emoji.domain
end
def custom_emoji?
object.custom_emoji.present?
end
end

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
class REST::EmojiReactedBySlimSerializer < ActiveModel::Serializer
belongs_to :account, serializer: REST::AccountSerializer
has_many :emoji_reactions, serializer: REST::EmojiReactedBySlimReactionSerializer
def attributes
{ account => emoji_reactions }
end
private
def account
object.first
end
def emoji_reactions
object.last
end
end