Add recipient email and milestone notifications on transfer create.
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:
isaacclad
2026-06-08 12:38:58 +00:00
co-authored by Cursor
parent 311b5b40bb
commit 7c4673adb6
15 changed files with 851 additions and 5 deletions
@@ -0,0 +1,78 @@
<?php
namespace Tests\Feature;
use App\Models\Transfer;
use App\Models\User;
use App\Notifications\TransferRecipientNotification;
use App\Services\Transfer\TransferRecipientMailService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Tests\Concerns\FakesTransferBilling;
use Tests\TestCase;
class TransferRecipientMailTest extends TestCase
{
use FakesTransferBilling;
use RefreshDatabase;
public function test_create_transfer_emails_recipient_when_created_milestone_selected(): void
{
Notification::fake();
Storage::fake('qr');
$this->fakeTransferBillingApi();
$user = User::create([
'public_id' => (string) Str::uuid(),
'name' => 'Sender',
'email' => 'sender+'.uniqid().'@example.com',
]);
$this->actingAs($user)->post(route('transfer.transfers.store'), [
'title' => 'Project files',
'recipient_email' => 'recipient@example.com',
'email_milestones' => ['created'],
'files' => [UploadedFile::fake()->create('brief.pdf', 100, 'application/pdf')],
])->assertRedirect();
Notification::assertSentOnDemand(
TransferRecipientNotification::class,
fn ($notification, $channels, $notifiable) => $notifiable->routes['mail'] === 'recipient@example.com',
);
}
public function test_recipient_day_milestone_is_sent_once(): void
{
Notification::fake();
$user = User::create([
'public_id' => (string) Str::uuid(),
'name' => 'Sender',
'email' => 'sender+'.uniqid().'@example.com',
]);
$transfer = Transfer::create([
'user_id' => $user->id,
'title' => 'Reminder test',
'recipient_email' => 'recipient@example.com',
'recipient_email_milestones' => ['7'],
'recipient_milestones_sent' => [],
'retention_days' => 30,
'paid_until' => now()->addDays(7)->startOfDay(),
'status' => Transfer::STATUS_ACTIVE,
'storage_bytes' => 1024,
]);
$service = app(TransferRecipientMailService::class);
$this->assertSame(1, $service->processDueMilestones());
$this->assertSame(0, $service->processDueMilestones());
$transfer->refresh();
$this->assertContains('7', $transfer->recipient_milestones_sent ?? []);
Notification::assertSentOnDemand(TransferRecipientNotification::class, 1);
}
}