Fix quote nesting at once, add quote_id

This commit is contained in:
noellabo 2020-02-21 21:49:06 +09:00
parent 27da15b734
commit fa350fdb2c

View file

@ -15,10 +15,11 @@ class REST::StatusSerializer < ActiveModel::Serializer
attribute :content, unless: :source_requested?
attribute :text, if: :source_requested?
attribute :quote_id, if: -> { object.quote? }
belongs_to :reblog, serializer: REST::StatusSerializer
belongs_to :application, if: :show_application?
belongs_to :account, serializer: REST::AccountSerializer
belongs_to :quote, serializer: REST::StatusSerializer
has_many :media_attachments, serializer: REST::MediaAttachmentSerializer
has_many :ordered_mentions, key: :mentions
@ -40,6 +41,10 @@ class REST::StatusSerializer < ActiveModel::Serializer
object.in_reply_to_account_id&.to_s
end
def quote_id
object.quote_id.to_s
end
def current_user?
!current_user.nil?
end
@ -168,3 +173,13 @@ class REST::StatusSerializer < ActiveModel::Serializer
end
end
end
class REST::NestedQuoteSerializer < REST::StatusSerializer
attribute :quote do
nil
end
end
class REST::StatusSerializer < ActiveModel::Serializer
belongs_to :quote, serializer: REST::NestedQuoteSerializer
end