flag_serializer.rb 625 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. class ActivityPub::FlagSerializer < ActiveModel::Serializer
  3. attributes :id, :type, :actor, :content
  4. attribute :virtual_object, key: :object
  5. def id
  6. # This is nil for now
  7. ActivityPub::TagManager.instance.uri_for(object)
  8. end
  9. def type
  10. 'Flag'
  11. end
  12. def actor
  13. ActivityPub::TagManager.instance.uri_for(instance_options[:account] || object.account)
  14. end
  15. def virtual_object
  16. [ActivityPub::TagManager.instance.uri_for(object.target_account)] + object.statuses.map { |s| ActivityPub::TagManager.instance.uri_for(s) }
  17. end
  18. def content
  19. object.comment
  20. end
  21. end