Add share-video-by-email feature
New POST /videos/{video}/share/email route (auth + throttled) handled by
VideoController@shareByEmail, sending the VideoShared mailable rendered from
emails/video-shared.blade.php. Wired into the share modal and video-actions.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
1 parent
a4384113c2
commit
d9959c4452
6 files changed
+274
-5
No files matched your search
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Video;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Address;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class VideoShared extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public string $shareTitle;
|
||||
|
||||
public function __construct(
|
||||
public Video $video,
|
||||
public string $shareUrl,
|
||||
public User $sender,
|
||||
public ?string $personalMessage = null,
|
||||
?string $shareTitle = null,
|
||||
) {
|
||||
// Version-aware title (e.g. the English track's title) with a primary fallback.
|
||||
$this->shareTitle = $shareTitle ?: $video->title;
|
||||
}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: $this->sender->name . ' shared "' . $this->shareTitle . '" with you on ' . config('app.name'),
|
||||
// Let the recipient reply straight to the friend who sent it.
|
||||
replyTo: $this->sender->email
|
||||
? [new Address($this->sender->email, $this->sender->name)]
|
||||
: [],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(view: 'emails.video-shared');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user