Deploy Ladill Transfer / deploy (push) Successful in 47s
Recipients always get the download link immediately when an email is set. Large files upload in the background with per-file and overall progress bars. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
936 B
PHP
36 lines
936 B
PHP
<?php
|
|
|
|
namespace App\Services\Transfer;
|
|
|
|
use App\Models\Transfer;
|
|
use App\Notifications\TransferRecipientNotification;
|
|
use Illuminate\Support\Facades\Notification;
|
|
|
|
/** Sends the immediate download-link email to transfer recipients. */
|
|
class TransferRecipientMailService
|
|
{
|
|
public function notifyRecipient(Transfer $transfer, string $milestone = 'created'): bool
|
|
{
|
|
if ($milestone !== 'created') {
|
|
return false;
|
|
}
|
|
|
|
$email = trim((string) $transfer->recipient_email);
|
|
if ($email === '') {
|
|
return false;
|
|
}
|
|
|
|
if ($transfer->recipientMilestoneSent('created')) {
|
|
return false;
|
|
}
|
|
|
|
Notification::route('mail', $email)->notify(
|
|
new TransferRecipientNotification($transfer->loadMissing(['files', 'qrCode', 'user']), 'created'),
|
|
);
|
|
|
|
$transfer->markRecipientMilestoneSent('created');
|
|
|
|
return true;
|
|
}
|
|
}
|