Add recipient email and milestone notifications on transfer create.
Deploy Ladill Transfer / deploy (push) Successful in 44s
Deploy Ladill Transfer / deploy (push) Successful in 44s
Recipients can be emailed the download link immediately and at optional reminders (7/3/1 days before unavailable, or when grace period starts). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Transfer;
|
||||
use App\Services\Qr\QrImageGeneratorService;
|
||||
use App\Services\Qr\QrPdfExporter;
|
||||
use App\Services\Transfer\TransferRecipientMailService;
|
||||
use App\Services\Transfer\TransferService;
|
||||
use App\Services\Upload\ChunkedUploadService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -41,10 +42,14 @@ class TransferController extends Controller
|
||||
|
||||
public function create(): View
|
||||
{
|
||||
$mailService = app(TransferRecipientMailService::class);
|
||||
|
||||
return view('transfer.transfers.create', [
|
||||
'maxFiles' => (int) config('transfer.max_files_per_transfer', 20),
|
||||
'pricePerGb' => (float) config('transfer.price_per_gb_month', 0.30),
|
||||
'gracePeriodDays' => (int) config('transfer.grace_period_days', 15),
|
||||
'emailMilestones' => $mailService->milestoneOptions(),
|
||||
'defaultEmailMilestones' => (array) config('transfer.default_recipient_email_milestones', ['created']),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -58,9 +63,14 @@ class TransferController extends Controller
|
||||
$fileRules[] = 'max:'.(int) ceil($maxBytes / 1024);
|
||||
}
|
||||
|
||||
$allowedMilestones = implode(',', app(TransferRecipientMailService::class)->allowedMilestones());
|
||||
|
||||
$data = $request->validate([
|
||||
'title' => 'required|string|max:120',
|
||||
'message' => 'nullable|string|max:2000',
|
||||
'recipient_email' => 'nullable|email|max:255|required_with:email_milestones',
|
||||
'email_milestones' => 'nullable|array',
|
||||
'email_milestones.*' => 'in:'.$allowedMilestones,
|
||||
'password' => 'nullable|string|min:4|max:64',
|
||||
'files' => 'nullable|array',
|
||||
'files.*' => $fileRules,
|
||||
@@ -94,9 +104,14 @@ class TransferController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$success = 'Transfer created. Share the link or QR code with recipients.';
|
||||
if ($transfer->recipient_email && $transfer->wantsRecipientMilestone('created') && $transfer->recipientMilestoneSent('created')) {
|
||||
$success .= ' A download link was emailed to '.$transfer->recipient_email.'.';
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('transfer.transfers.show', $transfer)
|
||||
->with('success', 'Transfer created. Share the link or QR code with recipients.');
|
||||
->with('success', $success);
|
||||
}
|
||||
|
||||
public function show(Transfer $transfer): View
|
||||
|
||||
Reference in New Issue
Block a user