logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

activity_serializer.rb (931B)


  1. # frozen_string_literal: true
  2. class ActivityPub::ActivitySerializer < ActiveModel::Serializer
  3. attributes :id, :type, :actor, :published, :to, :cc
  4. has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer, unless: :announce?
  5. attribute :proper_uri, key: :object, if: :announce?
  6. attribute :atom_uri, if: :announce?
  7. def id
  8. ActivityPub::TagManager.instance.activity_uri_for(object)
  9. end
  10. def type
  11. announce? ? 'Announce' : 'Create'
  12. end
  13. def actor
  14. ActivityPub::TagManager.instance.uri_for(object.account)
  15. end
  16. def published
  17. object.created_at.iso8601
  18. end
  19. def to
  20. ActivityPub::TagManager.instance.to(object)
  21. end
  22. def cc
  23. ActivityPub::TagManager.instance.cc(object)
  24. end
  25. def proper_uri
  26. ActivityPub::TagManager.instance.uri_for(object.proper)
  27. end
  28. def atom_uri
  29. OStatus::TagManager.instance.uri_for(object)
  30. end
  31. def announce?
  32. object.reblog?
  33. end
  34. end