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.

31 lines
737 B

  1. # frozen_string_literal: true
  2. class AfterRemoteFollowRequestWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'pull', retry: 5
  5. attr_reader :follow_request
  6. def perform(follow_request_id)
  7. @follow_request = FollowRequest.find(follow_request_id)
  8. process_follow_service if processing_required?
  9. rescue ActiveRecord::RecordNotFound
  10. true
  11. end
  12. private
  13. def process_follow_service
  14. follow_request.destroy
  15. FollowService.new.call(follow_request.account, updated_account.acct)
  16. end
  17. def processing_required?
  18. !updated_account.nil? && !updated_account.locked?
  19. end
  20. def updated_account
  21. @_updated_account ||= FetchRemoteAccountService.new.call(follow_request.target_account.remote_url)
  22. end
  23. end