diff options
Diffstat (limited to 'app/workers/refollow_worker.rb')
-rw-r--r-- | app/workers/refollow_worker.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/workers/refollow_worker.rb b/app/workers/refollow_worker.rb new file mode 100644 index 000000000..9c42d4271 --- /dev/null +++ b/app/workers/refollow_worker.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class RefollowWorker + include Sidekiq::Worker + + sidekiq_options queue: 'pull', retry: false + + def perform(target_account_id) + target_account = Account.find(target_account_id) + + target_account.followers.where(domain: nil).find_each do |follower| + # Locally unfollow remote account + follower.unfollow!(target_account) + + # Schedule re-follow + begin + FollowService.new.call(follower, target_account) + rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError + next + end + end + end +end |