2022-01-19 13:37:27 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class REST::StatusEditSerializer < ActiveModel::Serializer
|
2022-03-25 18:53:34 -07:00
|
|
|
include FormattingHelper
|
|
|
|
|
2022-02-08 16:17:07 -08:00
|
|
|
has_one :account, serializer: REST::AccountSerializer
|
|
|
|
|
2022-03-09 00:06:17 -08:00
|
|
|
attributes :content, :spoiler_text, :sensitive, :created_at
|
2022-02-08 16:17:07 -08:00
|
|
|
|
2022-03-09 00:06:17 -08:00
|
|
|
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
2022-02-08 16:17:07 -08:00
|
|
|
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
|
|
|
|
2022-03-09 00:06:17 -08:00
|
|
|
attribute :poll, if: -> { object.poll_options.present? }
|
|
|
|
|
2022-02-08 16:17:07 -08:00
|
|
|
def content
|
2022-03-25 18:53:34 -07:00
|
|
|
status_content_format(object)
|
2022-02-08 16:17:07 -08:00
|
|
|
end
|
2022-03-09 00:06:17 -08:00
|
|
|
|
|
|
|
def poll
|
|
|
|
{ options: object.poll_options.map { |title| { title: title } } }
|
|
|
|
end
|
2022-01-19 13:37:27 -08:00
|
|
|
end
|