From e050958794e436a61863cc62b0d7c54afb971ca4 Mon Sep 17 00:00:00 2001
From: NOGISAKA Sadata <ngsksdt@gmail.com>
Date: Sun, 24 Feb 2019 22:28:36 +0900
Subject: [PATCH] Skip some methods in BatchedRemoveStatusService when account
 is nil (#10095)

* Skip some methods in BatchedRemoveStatusService when account is nil

Sometimes `bin/tootctl accounts cull` fails with below error:

undefined method `followers_for_local_distribution' for nil:NilClass (NoMethodError)

This commit makes BatchedRemoveStatusService to skip below methods when
`account` is nil:

- unpush_from_home_timelines()
- unpush_from_list_timelines()
- batch_stream_entries()

* Fix rubocop error: Use `next` to skip iteration.
---
 app/services/batched_remove_status_service.rb | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/services/batched_remove_status_service.rb b/app/services/batched_remove_status_service.rb
index cd3b14e08..e328b1739 100644
--- a/app/services/batched_remove_status_service.rb
+++ b/app/services/batched_remove_status_service.rb
@@ -35,6 +35,8 @@ class BatchedRemoveStatusService < BaseService
     statuses.group_by(&:account_id).each_value do |account_statuses|
       account = account_statuses.first.account
 
+      next unless account
+
       unpush_from_home_timelines(account, account_statuses)
       unpush_from_list_timelines(account, account_statuses)