ghassan d9959c4452 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 <noreply@anthropic.com>
2026-05-24 14:12:01 +03:00

47 lines
1.3 KiB
PHP

<?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');
}
}