Files
ladill-transfer/app/Notifications/TransferRecipientNotification.php
T
isaaccladandCursor a0fce19402
Deploy Ladill Transfer / deploy (push) Successful in 48s
Fix transfer recipient emails not sending in production.
Map MAIL_ENCRYPTION to a valid SMTP scheme, send recipient notifications
synchronously, document mail/queue env vars, and add a supervisor worker template.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 15:04:19 +00:00

63 lines
1.9 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\Transfer;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class TransferRecipientNotification extends Notification
{
use Queueable;
public function __construct(
private readonly Transfer $transfer,
private readonly string $milestone,
) {}
public function via(mixed $notifiable): array
{
return ['mail'];
}
public function toMail(mixed $notifiable): MailMessage
{
$transfer = $this->transfer->loadMissing(['files', 'qrCode', 'user']);
$publicUrl = $transfer->qrCode?->publicUrl() ?? '';
return (new MailMessage())
->subject($this->subjectLine())
->view('mail.notifications.transfer-recipient', [
'transfer' => $transfer,
'publicUrl' => $publicUrl,
'milestone' => $this->milestone,
'senderName' => $transfer->user?->name,
'daysRemaining' => $this->daysRemaining(),
]);
}
private function subjectLine(): string
{
return match ($this->milestone) {
'created' => $this->transfer->user?->name
? "{$this->transfer->user->name} shared files with you"
: "Files shared with you: {$this->transfer->title}",
'grace' => "Download soon — {$this->transfer->title} needs payment",
'1' => "Last day to download: {$this->transfer->title}",
'3' => "3 days left to download: {$this->transfer->title}",
'7' => "Download reminder: {$this->transfer->title}",
default => "Download reminder: {$this->transfer->title}",
};
}
private function daysRemaining(): ?int
{
if (! is_numeric($this->milestone)) {
return null;
}
return (int) $this->milestone;
}
}