1
0

refollow_worker.rb 705 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. class RefollowWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'pull', retry: false
  5. def perform(target_account_id)
  6. target_account = Account.find(target_account_id)
  7. return unless target_account.protocol == :activitypub
  8. target_account.followers.where(domain: nil).find_each do |follower|
  9. # Locally unfollow remote account
  10. follower.unfollow!(target_account)
  11. # Schedule re-follow
  12. begin
  13. FollowService.new.call(follower, target_account)
  14. rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError
  15. next
  16. end
  17. end
  18. end
  19. end