about summary refs log tree commit diff
path: root/app/serializers/rest/status_edit_serializer.rb
blob: f7a48797d1a5c41e75889ea7a04bd71dbb68b7cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

class REST::StatusEditSerializer < ActiveModel::Serializer
  include FormattingHelper

  has_one :account, serializer: REST::AccountSerializer

  attributes :content, :spoiler_text, :sensitive, :created_at

  has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
  has_many :emojis, serializer: REST::CustomEmojiSerializer

  attribute :poll, if: -> { object.poll_options.present? }

  def content
    status_content_format(object)
  end

  def poll
    { options: object.poll_options.map { |title| { title: title } } }
  end
end