mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\MediaPipeline;
|
|
|
|
use App\Models\Media;
|
|
use App\Services\MediaStorageService;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class MediaStoragePipeline implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected $media;
|
|
|
|
public $deleteWhenMissingModels = true;
|
|
|
|
public function __construct(Media $media)
|
|
{
|
|
$this->media = $media;
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
$media = $this->media;
|
|
|
|
// Verify media exists
|
|
if (! $media) {
|
|
Log::info('MediaStoragePipeline: Media no longer exists, skipping job');
|
|
|
|
return;
|
|
}
|
|
|
|
// Verify media has required fields
|
|
if (! $media->media_path) {
|
|
Log::info("MediaStoragePipeline: Media {$media->id} has no media_path, skipping job");
|
|
|
|
return;
|
|
}
|
|
|
|
try {
|
|
MediaStorageService::store($media);
|
|
} catch (\Exception $e) {
|
|
Log::warning("MediaStoragePipeline: Failed to store media {$media->id}: ".$e->getMessage());
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|