The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

32 lines
666 B

  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