1
0

after_remote_follow_worker.rb 666 B

12345678910111213141516171819202122232425262728293031
  1. # frozen_string_literal: true
  2. class AfterRemoteFollowWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'pull', retry: 5
  5. attr_reader :follow
  6. def perform(follow_id)
  7. @follow = Follow.find(follow_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.destroy
  15. FollowService.new.call(follow.account, updated_account.acct)
  16. end
  17. def updated_account
  18. @_updated_account ||= FetchRemoteAccountService.new.call(follow.target_account.remote_url)
  19. end
  20. def processing_required?
  21. !updated_account.nil? && updated_account.locked?
  22. end
  23. end