WeeklyInstanceScan.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Instance;
  4. use App\Jobs\InstancePipeline\FetchNodeinfoPipeline;
  5. use Illuminate\Console\Command;
  6. use function Laravel\Prompts\progress;
  7. class WeeklyInstanceScan extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'app:weekly-instance-scan';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = 'Scan instance nodeinfo';
  21. /**
  22. * Execute the console command.
  23. */
  24. public function handle()
  25. {
  26. if ((bool) config_cache('federation.activitypub.enabled') == false) {
  27. return;
  28. }
  29. $users = progress(
  30. label: 'Updating instance stats...',
  31. steps: Instance::all(),
  32. callback: fn ($instance) => $this->updateInstanceStats($instance),
  33. );
  34. }
  35. protected function updateInstanceStats($instance)
  36. {
  37. FetchNodeinfoPipeline::dispatch($instance)->onQueue('intbg');
  38. }
  39. }