Class: ActivityPub::UpdateSerializer

Inherits:
BaseSerializer
  • Object
show all
Defined in:
app/serializers/activitypub/update_serializer.rb

Constant Summary

Constants inherited from BaseSerializer

BaseSerializer::CONTEXT

Instance Attribute Summary

Attributes inherited from BaseSerializer

#options

Instance Method Summary collapse

Methods inherited from BaseSerializer

#as_json, #initialize, #to_json

Constructor Details

This class inherits a constructor from ActivityPub::BaseSerializer

Instance Method Details

#actorObject



16
17
18
19
# File 'app/serializers/activitypub/update_serializer.rb', line 16

def actor
  resource = object.is_a?(Account) ? object : object.
  ActivityPub::TagManager.instance.uri_for(resource)
end

#dataObject



3
4
5
6
7
8
9
10
# File 'app/serializers/activitypub/update_serializer.rb', line 3

def data
  {
    id: id,
    type: 'Update',
    object: object_serialized,
    actor: actor
  }
end

#idObject



12
13
14
# File 'app/serializers/activitypub/update_serializer.rb', line 12

def id
  [ActivityPub::TagManager.instance.uri_for(object), '#updates/', object.updated_at.to_i].join
end

#object_serializedObject



21
22
23
24
25
26
27
28
29
30
# File 'app/serializers/activitypub/update_serializer.rb', line 21

def object_serialized
  case object
  when Account
    ActivityPub::ActorSerializer.new(object).data
  when Story
    ActivityPub::StorySerializer.new(object).data
  when Comment
    ActivityPub::CommentSerializer.new(object).data
  end
end