- New SportsMatch model/controller and sports UI components/modal - Move share-modal to a reusable x-share-modal/x-share-button component - Add VideoSharedWithUser notification and share-to-members flow - Device/user-agent tracking on views, downloads, share accesses - ProfileVisit model + migration; subscription source tracking - Email thumbnail support; remove stale TODO files
59 lines
1.9 KiB
PHP
59 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\User;
|
|
use App\Models\Video;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class VideoSharedWithUser extends Notification
|
|
{
|
|
public function __construct(
|
|
public Video $video,
|
|
public User $sharer,
|
|
public ?string $message,
|
|
public string $shareUrl,
|
|
) {}
|
|
|
|
/**
|
|
* A direct, person-to-person share is transactional — always deliver both
|
|
* the in-app notification and the email (not gated by subscription prefs).
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database', 'mail'];
|
|
}
|
|
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'type' => 'video_shared',
|
|
'video_id' => $this->video->id,
|
|
'video_route_key' => $this->video->getRouteKey(),
|
|
'video_title' => $this->video->title,
|
|
'video_thumbnail' => $this->video->thumbnail,
|
|
'actor_id' => $this->sharer->id,
|
|
'actor_name' => $this->sharer->name,
|
|
'actor_avatar' => $this->sharer->avatar_url,
|
|
'message' => $this->message,
|
|
];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$isSong = $this->video->isAudioOnly() || $this->video->type === 'music';
|
|
$noun = $isSong ? 'song' : ($this->video->type === 'match' ? 'match' : 'video');
|
|
|
|
return (new MailMessage)
|
|
->subject($this->sharer->name . ' shared a ' . $noun . ' with you')
|
|
->view('emails.video-shared', [
|
|
'video' => $this->video,
|
|
'sender' => $this->sharer,
|
|
'shareUrl' => $this->shareUrl,
|
|
'personalMessage' => $this->message,
|
|
'shareTitle' => $this->video->title,
|
|
]);
|
|
}
|
|
}
|