mastodon/app/serializers/rest/admin/moderation_note_serializer.rb
2024-11-20 20:19:26 +01:00

26 lines
659 B
Ruby

# frozen_string_literal: true
class REST::Admin::ModerationNoteSerializer < ActiveModel::Serializer
include RoutingHelper
attributes :id, :content, :created_at, :updated_at, :target
belongs_to :account, serializer: REST::Admin::AccountMinimalSerializer
def id
object.id.to_s
end
def content
object.content.strip
end
def target
case object
when ReportNote
{ type: 'Report', id: object.report_id.to_s, url: api_v1_admin_report_url(object.report.id) }
when AccountModerationNote
{ type: 'Account', id: object.target_account_id.to_s, url: api_v1_admin_account_url(object.target_account.id) }
end
end
end