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:
@@ -47,10 +47,24 @@ class TransferService
|
||||
$passwordHash = Hash::make((string) $data['password']);
|
||||
}
|
||||
|
||||
$recipientEmail = trim((string) ($data['recipient_email'] ?? ''));
|
||||
$recipientMilestones = app(TransferRecipientMailService::class)->normalizeMilestones(
|
||||
is_array($data['email_milestones'] ?? null) ? $data['email_milestones'] : [],
|
||||
);
|
||||
|
||||
if ($recipientEmail !== '' && $recipientMilestones === []) {
|
||||
$recipientMilestones = app(TransferRecipientMailService::class)->normalizeMilestones(
|
||||
(array) config('transfer.default_recipient_email_milestones', ['created']),
|
||||
);
|
||||
}
|
||||
|
||||
$transfer = Transfer::create([
|
||||
'user_id' => $user->id,
|
||||
'title' => trim((string) $data['title']),
|
||||
'message' => isset($data['message']) ? trim((string) $data['message']) : null,
|
||||
'recipient_email' => $recipientEmail !== '' ? $recipientEmail : null,
|
||||
'recipient_email_milestones' => $recipientEmail !== '' ? $recipientMilestones : null,
|
||||
'recipient_milestones_sent' => [],
|
||||
'password_hash' => $passwordHash,
|
||||
'retention_days' => $billingPeriodDays,
|
||||
'status' => Transfer::STATUS_ACTIVE,
|
||||
@@ -83,7 +97,10 @@ class TransferService
|
||||
$transfer = $transfer->fresh(['files', 'qrCode']);
|
||||
app(TransferBillingService::class)->chargeInitialPeriod($transfer, $user);
|
||||
|
||||
return $transfer->fresh(['files', 'qrCode']);
|
||||
$transfer = $transfer->fresh(['files', 'qrCode']);
|
||||
app(TransferRecipientMailService::class)->notifyRecipient($transfer, 'created');
|
||||
|
||||
return $transfer;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user