Add control room automations and uploader overrides
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-20 15:49:04 +01:00
parent e5e74febbd
commit 5e5b69f655
11 changed files with 738 additions and 33 deletions

View File

@@ -41,6 +41,35 @@ class GuestJoinTokenFlowTest extends TestCase
]);
}
private function seedGuestUploadPrerequisites(Event $event): void
{
$package = Package::factory()->endcustomer()->create([
'max_photos' => 100,
]);
EventPackage::create([
'event_id' => $event->id,
'package_id' => $package->id,
'purchased_price' => $package->price,
'purchased_at' => now(),
'used_photos' => 0,
'used_guests' => 0,
]);
MediaStorageTarget::create([
'key' => 'public',
'name' => 'Public',
'driver' => 'local',
'is_hot' => true,
'is_default' => true,
'is_active' => true,
]);
Mockery::mock('alias:App\Support\ImageHelper')
->shouldReceive('makeThumbnailOnDisk')
->andReturn("events/{$event->id}/photos/thumbs/generated_thumb.jpg")
->shouldReceive('copyWithWatermark')
->andReturnNull();
}
public function test_guest_can_access_stats_using_join_token(): void
{
$event = $this->createPublishedEvent();
@@ -67,33 +96,9 @@ class GuestJoinTokenFlowTest extends TestCase
Storage::fake('public');
$event = $this->createPublishedEvent();
$package = Package::factory()->endcustomer()->create([
'max_photos' => 100,
]);
EventPackage::create([
'event_id' => $event->id,
'package_id' => $package->id,
'purchased_price' => $package->price,
'purchased_at' => now(),
'used_photos' => 0,
'used_guests' => 0,
]);
MediaStorageTarget::create([
'key' => 'public',
'name' => 'Public',
'driver' => 'local',
'is_hot' => true,
'is_default' => true,
'is_active' => true,
]);
$this->seedGuestUploadPrerequisites($event);
$token = $this->tokenService->createToken($event);
Mockery::mock('alias:App\Support\ImageHelper')
->shouldReceive('makeThumbnailOnDisk')
->andReturn("events/{$event->id}/photos/thumbs/generated_thumb.jpg")
->shouldReceive('copyWithWatermark')
->andReturnNull();
$file = UploadedFile::fake()->image('example.jpg', 1200, 800);
$response = $this->withHeader('X-Device-Id', 'token-device')
@@ -125,6 +130,86 @@ class GuestJoinTokenFlowTest extends TestCase
}
}
public function test_force_review_uploader_overrides_immediate_visibility(): void
{
Storage::fake('public');
$event = $this->createPublishedEvent();
$event->update([
'settings' => [
'guest_upload_visibility' => 'immediate',
'control_room' => [
'auto_add_approved_to_live' => true,
'force_review_uploaders' => [
[
'device_id' => 'blocked-device',
'label' => 'Blocked',
],
],
],
],
]);
$this->seedGuestUploadPrerequisites($event);
$token = $this->tokenService->createToken($event);
$file = UploadedFile::fake()->image('example.jpg', 1200, 800);
$response = $this->withHeader('X-Device-Id', 'blocked-device')
->postJson("/api/v1/events/{$token->token}/upload", [
'photo' => $file,
'live_show_opt_in' => true,
]);
$response->assertCreated()
->assertJsonPath('status', 'pending');
$photo = Photo::first();
$this->assertNotNull($photo);
$this->assertSame('pending', $photo->status);
$this->assertSame(PhotoLiveStatus::REJECTED, $photo->live_status);
$this->assertSame('blocked-device', $photo->created_by_device_id);
}
public function test_trusted_uploader_auto_approves_and_adds_to_live_show(): void
{
Storage::fake('public');
$event = $this->createPublishedEvent();
$event->update([
'settings' => [
'guest_upload_visibility' => 'review',
'control_room' => [
'auto_add_approved_to_live' => true,
'trusted_uploaders' => [
[
'device_id' => 'trusted-device',
'label' => 'VIP',
],
],
],
],
]);
$this->seedGuestUploadPrerequisites($event);
$token = $this->tokenService->createToken($event);
$file = UploadedFile::fake()->image('example.jpg', 1200, 800);
$response = $this->withHeader('X-Device-Id', 'trusted-device')
->postJson("/api/v1/events/{$token->token}/upload", [
'photo' => $file,
]);
$response->assertCreated()
->assertJsonPath('status', 'approved');
$photo = Photo::first();
$this->assertNotNull($photo);
$this->assertSame('approved', $photo->status);
$this->assertSame(PhotoLiveStatus::APPROVED, $photo->live_status);
$this->assertNotNull($photo->live_submitted_at);
$this->assertNotNull($photo->live_approved_at);
}
public function test_guest_event_response_includes_demo_read_only_flag(): void
{
$event = $this->createPublishedEvent();