1
0
mirror of https://github.com/whippyshou/mastodon synced 2024-12-15 15:18:24 +09:00
whippy-edition/app/serializers/rest/status_edit_serializer.rb

21 lines
589 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class REST::StatusEditSerializer < ActiveModel::Serializer
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
Formatter.instance.format(object)
end
def poll
{ options: object.poll_options.map { |title| { title: title } } }
end
end