mirror of
https://github.com/glitch-soc/mastodon
synced 2025-04-24 15:24:51 +00:00
25 lines
646 B
Ruby
25 lines
646 B
Ruby
# frozen_string_literal: true
|
|
|
|
class REST::BaseQuoteSerializer < ActiveModel::Serializer
|
|
attributes :state
|
|
|
|
def state
|
|
return object.state unless object.accepted?
|
|
|
|
# Extra states when a status is unavailable
|
|
return 'deleted' if object.quoted_status.nil?
|
|
return 'unauthorized' if status_filter.filtered?
|
|
|
|
object.state
|
|
end
|
|
|
|
def quoted_status
|
|
object.quoted_status if object.accepted? && object.quoted_status.present? && !status_filter.filtered?
|
|
end
|
|
|
|
private
|
|
|
|
def status_filter
|
|
@status_filter ||= StatusFilter.new(object.quoted_status, current_user&.account, instance_options[:relationships] || {})
|
|
end
|
|
end
|