mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-20 20:13:17 +00:00
55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Console\Commands;
|
||
|
|
||
|
use Illuminate\Console\Command;
|
||
|
use App\Models\ImportPost;
|
||
|
use App\Jobs\ImportPipeline\ImportMediaToCloudPipeline;
|
||
|
use function Laravel\Prompts\progress;
|
||
|
|
||
|
class ImportUploadMediaToCloudStorage extends Command
|
||
|
{
|
||
|
/**
|
||
|
* The name and signature of the console command.
|
||
|
*
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $signature = 'app:import-upload-media-to-cloud-storage {--limit=500}';
|
||
|
|
||
|
/**
|
||
|
* The console command description.
|
||
|
*
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $description = 'Migrate media imported from Instagram to S3 cloud storage.';
|
||
|
|
||
|
/**
|
||
|
* Execute the console command.
|
||
|
*/
|
||
|
public function handle()
|
||
|
{
|
||
|
if(
|
||
|
(bool) config('import.instagram.storage.cloud.enabled') === false ||
|
||
|
(bool) config_cache('pixelfed.cloud_storage') === false
|
||
|
) {
|
||
|
$this->error('Aborted. Cloud storage is not enabled for IG imports.');
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$limit = $this->option('limit');
|
||
|
|
||
|
$progress = progress(label: 'Migrating import media', steps: $limit);
|
||
|
|
||
|
$progress->start();
|
||
|
|
||
|
$posts = ImportPost::whereUploadedToS3(false)->take($limit)->get();
|
||
|
|
||
|
foreach($posts as $post) {
|
||
|
ImportMediaToCloudPipeline::dispatch($post)->onQueue('low');
|
||
|
$progress->advance();
|
||
|
}
|
||
|
|
||
|
$progress->finish();
|
||
|
}
|
||
|
}
|