mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
30 lines
699 B
Ruby
30 lines
699 B
Ruby
# frozen_string_literal: true
|
|
|
|
class REST::CollectionSerializer < ActiveModel::Serializer
|
|
attributes :id, :uri, :name, :description, :language, :account_id,
|
|
:local, :sensitive, :discoverable, :item_count,
|
|
:created_at, :updated_at
|
|
|
|
belongs_to :tag, serializer: REST::StatusSerializer::TagSerializer
|
|
|
|
has_many :items, serializer: REST::CollectionItemSerializer
|
|
|
|
def id
|
|
object.id.to_s
|
|
end
|
|
|
|
def description
|
|
return object.description if object.local?
|
|
|
|
Sanitize.fragment(object.description_html, Sanitize::Config::MASTODON_STRICT)
|
|
end
|
|
|
|
def items
|
|
object.items_for(current_user&.account)
|
|
end
|
|
|
|
def account_id
|
|
object.account_id.to_s
|
|
end
|
|
end
|