mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
24 lines
647 B
Ruby
24 lines
647 B
Ruby
|
# 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
|