Class: ActivityPub::CollectionSerializer

Inherits:
ApplicationSerializer show all
Defined in:
app/serializers/activity_pub/collection_serializer.rb

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

#federate?, #to

Methods inherited from BaseSerializer

#audience, #bcc, #bto, #federate?, #initialize, #to

Constructor Details

This class inherits a constructor from ActivityPub::BaseSerializer

Instance Method Details

#cc ⇒ Object



26
27
28
29
30
31
32
# File 'app/serializers/activity_pub/collection_serializer.rb', line 26

def cc
  [
    @object.federails_actor.followers_url,
    @object.creator&.federails_actor&.followers_url,
    @object.collection&.federails_actor&.followers_url
  ].compact
end

#serialize ⇒ Object

Raises:

  • (ActiveRecord::RecordNotFound)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/serializers/activity_pub/collection_serializer.rb', line 3

def serialize
  raise ActiveRecord::RecordNotFound unless federate? # Temporary guard against publishing non-public Federails::ActorEntity objects
  {
    "@context": [
      {
        f3di: "http://purl.org/f3di/ns#",
        toot: "http://joinmastodon.org/ns#",
        indexable: "toot:indexable",
        discoverable: "toot:discoverable"
      }
    ],
    summary: @object.caption,
    content: @object.notes,
    "f3di:concreteType": "Collection",
    indexable: @object.indexable?,
    discoverable: @object.indexable?,
    attachment: @object.links.map { {type: "Link", href: it.url, name: it.text}.compact },
    attributedTo: short_creator(@object.creator),
    context: short_collection(@object.collection),
    preview: oembed_to_preview(OEmbed::CollectionSerializer.new(@object, maxwidth: "100%", maxheight: "100%").serialize)
  }.merge(address_fields)
end