1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-27 18:26:50 +00:00
pixelfed/app/Console/Commands/SeedFollows.php

67 lines
1.5 KiB
PHP
Raw Normal View History

2018-05-30 03:01:28 +00:00
<?php
namespace App\Console\Commands;
2018-08-28 03:07:36 +00:00
use App\Follower;
2018-05-30 03:01:28 +00:00
use App\Jobs\FollowPipeline\FollowPipeline;
2018-08-28 03:07:36 +00:00
use App\Profile;
use Illuminate\Console\Command;
2018-05-30 03:01:28 +00:00
class SeedFollows extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'seed:follows';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Seed follows for testing';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
2019-05-13 07:09:36 +00:00
$limit = 100;
2018-05-30 03:01:28 +00:00
2018-08-28 03:07:36 +00:00
for ($i = 0; $i < $limit; $i++) {
2018-05-30 03:01:28 +00:00
try {
2019-05-13 07:09:36 +00:00
$actor = Profile::whereDomain(false)->inRandomOrder()->firstOrFail();
$target = Profile::whereDomain(false)->inRandomOrder()->firstOrFail();
2018-05-30 03:01:28 +00:00
2019-05-13 07:09:36 +00:00
if($actor->id == $target->id) {
continue;
}
2018-05-30 03:01:28 +00:00
2019-05-13 07:09:36 +00:00
$follow = Follower::firstOrCreate([
'profile_id' => $actor->id,
'following_id' => $target->id
]);
if($follow->wasRecentlyCreated == true) {
FollowPipeline::dispatch($follow);
}
2018-05-30 03:01:28 +00:00
} catch (Exception $e) {
continue;
}
}
}
}