The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

53 lines
1.2 KiB

  1. # frozen_string_literal: true
  2. class ActivityPub::VoteSerializer < ActiveModel::Serializer
  3. class NoteSerializer < ActiveModel::Serializer
  4. attributes :id, :type, :name, :attributed_to,
  5. :in_reply_to, :to
  6. def id
  7. ActivityPub::TagManager.instance.uri_for(object) || [ActivityPub::TagManager.instance.uri_for(object.account), '#votes/', object.id].join
  8. end
  9. def type
  10. 'Note'
  11. end
  12. def name
  13. object.poll.options[object.choice.to_i]
  14. end
  15. def attributed_to
  16. ActivityPub::TagManager.instance.uri_for(object.account)
  17. end
  18. def in_reply_to
  19. ActivityPub::TagManager.instance.uri_for(object.poll.status)
  20. end
  21. def to
  22. ActivityPub::TagManager.instance.uri_for(object.poll.account)
  23. end
  24. end
  25. attributes :id, :type, :actor, :to
  26. has_one :object, serializer: ActivityPub::VoteSerializer::NoteSerializer
  27. def id
  28. [ActivityPub::TagManager.instance.uri_for(object.account), '#votes/', object.id, '/activity'].join
  29. end
  30. def type
  31. 'Create'
  32. end
  33. def actor
  34. ActivityPub::TagManager.instance.uri_for(object.account)
  35. end
  36. def to
  37. ActivityPub::TagManager.instance.uri_for(object.poll.account)
  38. end
  39. end