# frozen_string_literal: true
class ActivityPub::ActivitySerializer < ActiveModel::Serializer
attributes :id, :type, :actor, :published, :to, :cc
has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer, unless: :announce?
attribute :proper_uri, key: :object, if: :announce?
def id
ActivityPub::TagManager.instance.activity_uri_for(object)
end
def type
announce? ? 'Announce' : 'Create'
def actor
ActivityPub::TagManager.instance.uri_for(object.account)
def published
object.created_at.iso8601
def to
ActivityPub::TagManager.instance.to(object)
def cc
ActivityPub::TagManager.instance.cc(object)
def proper_uri
ActivityPub::TagManager.instance.uri_for(object.proper)
def announce?
object.reblog?