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