Skip to content

Commit

Permalink
fixes #1686 by providing default absolute path if not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria committed Sep 2, 2023
1 parent cc9a6d4 commit bf76ebf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/Console/Commands/PhotosAddedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Illuminate\Console\Command;
use Illuminate\Notifications\DatabaseNotification;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;

class PhotosAddedNotification extends Command
{
Expand Down Expand Up @@ -59,6 +61,12 @@ public function handle(): int

$thumbUrl = $photo->size_variants->getThumb()?->url;

// Mail clients do not like relative paths.
// if url does not start with 'http', it is not absolute...
if (!Str::startsWith('http', $thumbUrl)) {
$thumbUrl = URL::asset($thumbUrl);
}

// If the url config doesn't contain a trailing slash then add it
if (str_ends_with(config('app.url'), '/')) {
$trailing_slash = '';
Expand Down
1 change: 1 addition & 0 deletions app/Models/SizeVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\URL;
use League\Flysystem\Local\LocalFilesystemAdapter;

// TODO: Uncomment the following line, if Lychee really starts to support AWS s3.
Expand Down

0 comments on commit bf76ebf

Please sign in to comment.