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