mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 16:23:16 +00:00
50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Console\Commands;
|
||
|
|
||
|
use Illuminate\Console\Command;
|
||
|
use App\Models\ImportPost;
|
||
|
use Storage;
|
||
|
use App\Services\ImportService;
|
||
|
|
||
|
class ImportUploadGarbageCollection extends Command
|
||
|
{
|
||
|
/**
|
||
|
* The name and signature of the console command.
|
||
|
*
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $signature = 'app:import-upload-garbage-collection';
|
||
|
|
||
|
/**
|
||
|
* The console command description.
|
||
|
*
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $description = 'Command description';
|
||
|
|
||
|
/**
|
||
|
* Execute the console command.
|
||
|
*/
|
||
|
public function handle()
|
||
|
{
|
||
|
if(!config('import.instagram.enabled')) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$ips = ImportPost::whereNull('status_id')->whereSkipMissingMedia(true)->take(100)->get();
|
||
|
|
||
|
if(!$ips->count()) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
foreach($ips as $ip) {
|
||
|
$pid = $ip->profile_id;
|
||
|
$ip->delete();
|
||
|
ImportService::getPostCount($pid, true);
|
||
|
ImportService::clearAttempts($pid);
|
||
|
ImportService::getImportedFiles($pid, true);
|
||
|
}
|
||
|
}
|
||
|
}
|