Add emoji_reactions property to status api object

This commit is contained in:
KMY 2023-02-23 20:32:27 +09:00
parent 0ebf8b302d
commit 092f9916b0
7 changed files with 73 additions and 2 deletions

View file

@ -0,0 +1,31 @@
# frozen_string_literal: true
# name: string,
#count: number,
#account_ids: Array<string>,
#me: boolean,
#url: string,
#domain: string
class REST::EmojiReactionsGroupedByNameSerializer < ActiveModel::Serializer
attributes :name, :count
attribute :me, if: :current_user?
attribute :url, if: :custom_emoji?
attribute :static_url, if: :custom_emoji?
attribute :domain, if: :custom_emoji?
attribute :account_ids, if: :has_account_ids?
def current_user?
!current_user.nil?
end
def custom_emoji?
object.respond_to?(:custom_emoji)
end
def has_account_ids?
object.respond_to?(:account_ids)
end
end