Commit 56b8567e authored by ThibG's avatar ThibG Committed by Nathan Ladd
Browse files

Fix RefollowWorker not keeping show_reblogs setting (#12707)

* Fix RefollowWorker not keeping show_reblogs setting

* Fix RefollowWorker
parent 4fd3f776
......@@ -7,15 +7,18 @@ class RefollowWorker
def perform(target_account_id)
target_account = Account.find(target_account_id)
return unless target_account.protocol == :activitypub
return unless target_account.activitypub?
target_account.passive_relationships.where(account: Account.where(domain: nil)).includes(:account).reorder(nil).find_each do |follow|
reblogs = follow.show_reblogs?
target_account.followers.where(domain: nil).reorder(nil).find_each do |follower|
# Locally unfollow remote account
follower = follow.account
# Schedule re-follow
begin, target_account), target_account, reblogs: reblogs)
rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError
# frozen_string_literal: true
require 'rails_helper'
describe RefollowWorker do
subject { }
let(:account) { Fabricate(:account, domain: '', protocol: :activitypub) }
let(:alice) { Fabricate(:account, domain: nil, username: 'alice') }
let(:bob) { Fabricate(:account, domain: nil, username: 'bob') }
describe 'perform' do
let(:service) { double }
before do
allow(FollowService).to receive(:new).and_return(service)
allow(service).to receive(:call)
alice.follow!(account, reblogs: true)
bob.follow!(account, reblogs: false)
it 'calls FollowService for local followers' do
result = subject.perform(
expect(result).to be_nil
expect(service).to have_received(:call).with(alice, account, reblogs: true)
expect(service).to have_received(:call).with(bob, account, reblogs: false)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment