2017-07-14 18:01:39 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ActivityPub::ActivitySerializer < ActiveModel::Serializer
|
2017-09-18 11:30:11 -07:00
|
|
|
attributes :id, :type, :actor, :published, :to, :cc
|
2017-07-14 18:01:39 -07:00
|
|
|
|
|
|
|
has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer
|
|
|
|
|
|
|
|
def id
|
2017-08-24 07:21:42 -07:00
|
|
|
[ActivityPub::TagManager.instance.activity_uri_for(object)].join
|
2017-07-14 18:01:39 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def type
|
2017-08-26 10:55:10 -07:00
|
|
|
announce? ? 'Announce' : 'Create'
|
2017-07-14 18:01:39 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def actor
|
|
|
|
ActivityPub::TagManager.instance.uri_for(object.account)
|
|
|
|
end
|
|
|
|
|
2017-09-18 11:30:11 -07:00
|
|
|
def published
|
|
|
|
object.created_at.iso8601
|
|
|
|
end
|
|
|
|
|
2017-07-14 18:01:39 -07:00
|
|
|
def to
|
|
|
|
ActivityPub::TagManager.instance.to(object)
|
|
|
|
end
|
|
|
|
|
|
|
|
def cc
|
|
|
|
ActivityPub::TagManager.instance.cc(object)
|
|
|
|
end
|
2017-08-26 10:55:10 -07:00
|
|
|
|
|
|
|
def announce?
|
|
|
|
object.reblog?
|
|
|
|
end
|
2017-07-14 18:01:39 -07:00
|
|
|
end
|