followers_synchronizations_controller.rb 923 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # frozen_string_literal: true
  2. class ActivityPub::FollowersSynchronizationsController < ActivityPub::BaseController
  3. include SignatureVerification
  4. include AccountOwnedConcern
  5. vary_by -> { 'Signature' if authorized_fetch_mode? }
  6. before_action :require_account_signature!
  7. before_action :set_items
  8. def show
  9. expires_in 0, public: false
  10. render json: collection_presenter,
  11. serializer: ActivityPub::CollectionSerializer,
  12. adapter: ActivityPub::Adapter,
  13. content_type: 'application/activity+json'
  14. end
  15. private
  16. def uri_prefix
  17. signed_request_account.uri[Account::URL_PREFIX_RE]
  18. end
  19. def set_items
  20. @items = @account.followers.matches_uri_prefix(uri_prefix).pluck(:uri)
  21. end
  22. def collection_presenter
  23. ActivityPub::CollectionPresenter.new(
  24. id: account_followers_synchronization_url(@account),
  25. type: :ordered,
  26. items: @items
  27. )
  28. end
  29. end