diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/monsterfork.rake | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/tasks/monsterfork.rake b/lib/tasks/monsterfork.rake index 6ca7f54df..eeddeb3df 100644 --- a/lib/tasks/monsterfork.rake +++ b/lib/tasks/monsterfork.rake @@ -13,4 +13,22 @@ namespace :monsterfork do end end end + + desc 'Mark known instance actors.' + task mark_known_instance_actors: :environment do + Rails.logger.info('Gathering known domains...') + known_account_ids = Status.where(id: Status.local.reblogs.reorder(nil).select(:reblog_of_id)).reorder(nil).pluck(:account_id) | + Status.where(id: Favourite.select(:status_id)).reorder(nil).pluck(:account_id) | + Account.local.flat_map { |account| account.following_ids | account.follower_ids } + + known_domains = Account.select(:domain).distinct.where(id: known_account_ids).where.not(domain: nil).pluck(:domain) + + known_domains.each do |domain| + instance_actor = Account.find_remote(domain, domain) + next if instance_actor.nil? + + Rails.logger.info("Marking instance actor known for: #{domain}") + instance_actor.update!(known: true) + end + end end |