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.

27 lines
847 B

  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.activitypub?
  8. target_account.passive_relationships.where(account: Account.where(domain: nil)).includes(:account).reorder(nil).find_each do |follow|
  9. reblogs = follow.show_reblogs?
  10. # Locally unfollow remote account
  11. follower = follow.account
  12. follower.unfollow!(target_account)
  13. # Schedule re-follow
  14. begin
  15. FollowService.new.call(follower, target_account, reblogs: reblogs)
  16. rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError
  17. next
  18. end
  19. end
  20. end
  21. end