followers_synchronizations_controller.rb 860 B

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