Files
dredgegram/app/Services/StoryMediaCacher.php
T
dredgy b2f2d8b104
linter / quality (push) Canceled after 0s
tests / ci (8.3) (push) Canceled after 0s
tests / ci (8.4) (push) Canceled after 0s
tests / ci (8.5) (push) Canceled after 0s
Initial Commit
2026-08-29 00:17:41 +10:00

28 lines
604 B
PHP

<?php
namespace App\Services;
use App\Models\Story;
class StoryMediaCacher extends MediaCacher
{
public function cache(Story $story): void
{
$dirty = false;
if ($resolved = $this->resolveUrl($story->image_url, "stories/images/{$story->id}")) {
$story->image_url = $resolved;
$dirty = true;
}
if ($resolved = $this->resolveUrl($story->video_url, "stories/videos/{$story->id}")) {
$story->video_url = $resolved;
$dirty = true;
}
if ($dirty) {
$story->saveQuietly();
}
}
}