From 3a4d994c40962a9abe45565a34e3d7a3ca1ccd49 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 1 Oct 2019 15:10:00 +0200 Subject: Fix BootstrapTimelineService crashing when bootstrapped accounts are invalid (#12037) * Add test to handle suspended and missing users in BootstrapTimelineService * Fix BootstrapTimelineService crashing when bootstrapped accounts are invalid --- app/services/bootstrap_timeline_service.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/services/bootstrap_timeline_service.rb') diff --git a/app/services/bootstrap_timeline_service.rb b/app/services/bootstrap_timeline_service.rb index db2c83e5d..c489601c1 100644 --- a/app/services/bootstrap_timeline_service.rb +++ b/app/services/bootstrap_timeline_service.rb @@ -17,7 +17,11 @@ class BootstrapTimelineService < BaseService def autofollow_bootstrap_timeline_accounts! bootstrap_timeline_accounts.each do |target_account| - FollowService.new.call(@source_account, target_account) + begin + FollowService.new.call(@source_account, target_account) + rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError + nil + end end end @@ -40,7 +44,9 @@ class BootstrapTimelineService < BaseService def local_unlocked_accounts(usernames) Account.local + .without_suspended .where(username: usernames) .where(locked: false) + .where(moved_to_account_id: nil) end end -- cgit