This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2022-09-23 14:00:12 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class REST::TranslationSerializer < ActiveModel::Serializer
|
2023-05-31 15:10:21 -07:00
|
|
|
attributes :detected_source_language, :language, :provider, :spoiler_text, :content
|
2022-09-23 14:00:12 -07:00
|
|
|
|
2023-05-31 15:10:21 -07:00
|
|
|
class PollSerializer < ActiveModel::Serializer
|
|
|
|
attribute :id
|
|
|
|
has_many :options
|
|
|
|
|
|
|
|
def id
|
|
|
|
object.status.preloadable_poll.id.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def options
|
|
|
|
object.poll_options
|
|
|
|
end
|
|
|
|
|
|
|
|
class OptionSerializer < ActiveModel::Serializer
|
|
|
|
attributes :title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
has_one :poll, serializer: PollSerializer
|
|
|
|
|
|
|
|
class MediaAttachmentSerializer < ActiveModel::Serializer
|
|
|
|
attributes :id, :description
|
|
|
|
|
|
|
|
def id
|
|
|
|
object.id.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
has_many :media_attachments, serializer: MediaAttachmentSerializer
|
|
|
|
|
|
|
|
def poll
|
|
|
|
object if object.status.preloadable_poll
|
2022-09-23 14:00:12 -07:00
|
|
|
end
|
|
|
|
end
|