Mastodon/app/serializers/activitypub/featured_collection_serializer.rb
2026-04-16 07:26:34 +00:00

65 lines
1.3 KiB
Ruby

# frozen_string_literal: true
class ActivityPub::FeaturedCollectionSerializer < ActivityPub::Serializer
# include Rails.application.routes.url_helpers
include RoutingHelper
attributes :id, :type, :total_items, :name, :attributed_to, :url,
:sensitive, :discoverable, :published, :updated
attribute :summary, unless: :language_present?
attribute :summary_map, if: :language_present?
has_one :topic, serializer: ActivityPub::NoteSerializer::TagSerializer
has_many :collection_items, key: :ordered_items, serializer: ActivityPub::FeaturedItemSerializer
def id
ActivityPub::TagManager.instance.uri_for(object)
end
def type
'FeaturedCollection'
end
def summary
object.description
end
def summary_map
{ object.language => object.description }
end
def attributed_to
ActivityPub::TagManager.instance.uri_for(object.account)
end
def url
account_collection_url(object.account, object)
end
def total_items
object.accepted_collection_items.size
end
def published
object.created_at.iso8601
end
def updated
object.updated_at.iso8601
end
def language_present?
object.language.present?
end
def collection_items
object.accepted_collection_items
end
def topic
object.tag
end
end