fedibird-fe/app/serializers/activitypub/activity_serializer.rb

28 lines
601 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class ActivityPub::ActivitySerializer < ActivityPub::Serializer
2020-06-02 17:24:53 +00:00
def self.serializer_for(model, options)
case model.class.name
when 'Status'
ActivityPub::NoteSerializer
when 'DeliverToDeviceService::EncryptedMessage'
ActivityPub::EncryptedMessageSerializer
else
super
end
end
2020-06-02 17:24:53 +00:00
attributes :id, :type, :actor, :published, :to, :cc
2021-07-16 06:38:50 +00:00
attribute :expiry, if: -> { object.expiry.present? }
2020-06-02 17:24:53 +00:00
has_one :virtual_object, key: :object
def published
2020-06-02 17:24:53 +00:00
object.published.iso8601
end
2021-07-16 06:38:50 +00:00
def expiry
object.expiry.iso8601
end
end