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