pixelfed/app/Console/Commands/DeleteRemoteProfile.php

52 lines
1.4 KiB
PHP
Raw Normal View History

2024-07-19 05:06:57 +00:00
<?php
namespace App\Console\Commands;
use App\Jobs\DeletePipeline\DeleteRemoteProfilePipeline;
2024-07-19 06:21:34 +00:00
use App\Profile;
use Illuminate\Console\Command;
2024-07-19 05:06:57 +00:00
use function Laravel\Prompts\confirm;
2024-07-19 06:21:34 +00:00
use function Laravel\Prompts\search;
2024-07-19 05:06:57 +00:00
class DeleteRemoteProfile extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:delete-remote-profile';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete remote profile';
/**
* Execute the console command.
*/
public function handle()
{
$id = search(
'Search for the account',
fn (string $value) => strlen($value) > 2
2024-07-19 06:21:34 +00:00
? Profile::whereNotNull('domain')->where('username', 'like', $value.'%')->pluck('username', 'id')->all()
2024-07-19 05:06:57 +00:00
: []
);
$profile = Profile::whereNotNull('domain')->find($id);
2024-07-19 06:21:34 +00:00
if (! $profile) {
2024-07-19 05:06:57 +00:00
$this->error('Could not find profile.');
exit;
}
2024-07-19 06:21:34 +00:00
$confirmed = confirm('Are you sure you want to delete '.$profile->username.'\'s account? This action cannot be reversed.');
DeleteRemoteProfilePipeline::dispatch($profile)->onQueue('adelete');
2024-07-19 05:06:57 +00:00
$this->info('Dispatched delete job, it may take a few minutes...');
exit;
}
}