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