Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #1686 by providing absolute path if not set #1998

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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