followers_synchronizations_controller.rb 1008 B

123456789101112131415161718192021222324252627282930313233343536
  1. # frozen_string_literal: true
  2. class ActivityPub::FollowersSynchronizationsController < ActivityPub::BaseController
  3. include SignatureVerification
  4. include AccountOwnedConcern
  5. before_action :require_signature!
  6. before_action :set_items
  7. before_action :set_cache_headers
  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.where(Account.arel_table[:uri].matches("#{Account.sanitize_sql_like(uri_prefix)}/%", false, true)).or(@account.followers.where(uri: 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