Class: ActivityPub::CreatorSerializer

Inherits:
ApplicationSerializer show all
Defined in:
app/serializers/activity_pub/creator_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



38
39
40
# File 'app/serializers/activity_pub/creator_serializer.rb', line 38

def cc
  @object.federails_actor.followers_url
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
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/serializers/activity_pub/creator_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",
      attributionDomains: {
        "@id": "toot:attributionDomains",
        "@type": "@id"
      }
    },
    summary: @object.caption,
    content: @object.notes,
    attributionDomains: [
      [Rails.application.default_url_options[:host], Rails.application.default_url_options[:port]].compact.join(":")
    ],
    "f3di:concreteType": "Creator",
    indexable: @object.indexable?,
    discoverable: @object.indexable?,
    attachment: @object.links.map { {type: "Link", href: it.url, name: it.text}.compact },
    icon: @object.avatar ? {
      type: "Image",
      mediaType: @object.avatar.mime_type,
      url: Rails.application.routes.url_helpers.avatar_creator_url(@object)
    } : nil,
    image: @object.banner ? {
      type: "Image",
      mediaType: @object.banner.mime_type,
      url: Rails.application.routes.url_helpers.banner_creator_url(@object)
    } : nil
  }.merge(address_fields)
end