Gib Website-Bilder aus dem Medienmanager frei, ohne sie zu lizenzieren.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
72130d66c5
commit
13530b8171
18 files changed
+940
-2
No files matched your search
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\ThumbnailDeriver;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class AcceptWebsiteImage implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public int $elementId,
|
||||
public string $incoming,
|
||||
public ?int $actorId = null,
|
||||
) {}
|
||||
|
||||
public function handle(ThumbnailDeriver $deriver, WebsiteRelease $release): void
|
||||
{
|
||||
$element = ContentElement::query()->find($this->elementId);
|
||||
|
||||
if (! $element instanceof ContentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
$deriver->forWebsiteImage($element, $this->incoming);
|
||||
$element->refresh();
|
||||
|
||||
if ($release->derivedPath($element) === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->incomingIsDisposable()) {
|
||||
Storage::disk('cms_incoming')->delete($this->incoming);
|
||||
}
|
||||
|
||||
PublishWebsiteMedia::dispatch($element->id, 'release', $this->actorId);
|
||||
}
|
||||
|
||||
private function incomingIsDisposable(): bool
|
||||
{
|
||||
return (str_starts_with($this->incoming, 'cms/') || str_starts_with($this->incoming, 'vorschau/'))
|
||||
&& ! str_contains($this->incoming, '..');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user