Add guest Live Show opt-in toggle

This commit is contained in:
Codex Agent
2026-01-05 15:29:59 +01:00
parent 15be3b847c
commit 35ef8f1586
8 changed files with 116 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ use App\Enums\GuestNotificationAudience;
use App\Enums\GuestNotificationDeliveryStatus;
use App\Enums\GuestNotificationState;
use App\Enums\GuestNotificationType;
use App\Enums\PhotoLiveStatus;
use App\Events\GuestPhotoUploaded;
use App\Jobs\ProcessPhotoSecurityScan;
use App\Models\Event;
@@ -1899,6 +1900,8 @@ class EventPublicController extends BaseController
$branding = $this->buildGalleryBranding($event);
$settings = $this->normalizeSettings($event->settings ?? []);
$engagementMode = $settings['engagement_mode'] ?? 'tasks';
$liveShowSettings = Arr::get($settings, 'live_show', []);
$liveShowSettings = is_array($liveShowSettings) ? $liveShowSettings : [];
$event->loadMissing('photoboothSetting');
$policy = $this->guestPolicy();
@@ -1921,6 +1924,9 @@ class EventPublicController extends BaseController
'photobooth_enabled' => (bool) ($event->photoboothSetting?->enabled),
'branding' => $branding,
'guest_upload_visibility' => Arr::get($event->settings ?? [], 'guest_upload_visibility', $policy->guest_upload_visibility),
'live_show' => [
'moderation_mode' => $liveShowSettings['moderation_mode'] ?? 'manual',
],
'engagement_mode' => $engagementMode,
])->header('Cache-Control', 'no-store');
}
@@ -2987,6 +2993,7 @@ class EventPublicController extends BaseController
'emotion_slug' => ['nullable', 'string'],
'task_id' => ['nullable', 'integer'],
'guest_name' => ['nullable', 'string', 'max:255'],
'live_show_opt_in' => ['nullable', 'boolean'],
]);
$file = $validated['photo'];
@@ -3022,6 +3029,26 @@ class EventPublicController extends BaseController
$url = $this->resolveDiskUrl($disk, $watermarkedPath);
$thumbUrl = $this->resolveDiskUrl($disk, $watermarkedThumb);
$liveShowSettings = Arr::get($eventModel->settings ?? [], 'live_show', []);
$liveShowSettings = is_array($liveShowSettings) ? $liveShowSettings : [];
$liveModerationMode = $liveShowSettings['moderation_mode'] ?? 'manual';
$liveOptIn = $request->boolean('live_show_opt_in');
$liveSubmittedAt = null;
$liveApprovedAt = null;
$liveReviewedAt = null;
$liveStatus = PhotoLiveStatus::NONE->value;
if ($liveOptIn) {
$liveSubmittedAt = now();
if ($liveModerationMode === 'off') {
$liveStatus = PhotoLiveStatus::APPROVED->value;
$liveApprovedAt = $liveSubmittedAt;
$liveReviewedAt = $liveSubmittedAt;
} else {
$liveStatus = PhotoLiveStatus::PENDING->value;
}
}
$photoId = DB::table('photos')->insertGetId([
'event_id' => $eventId,
'tenant_id' => $tenantModel->id,
@@ -3033,6 +3060,12 @@ class EventPublicController extends BaseController
'likes_count' => 0,
'ingest_source' => Photo::SOURCE_GUEST_PWA,
'status' => $autoApproveUploads ? 'approved' : 'pending',
'live_status' => $liveStatus,
'live_submitted_at' => $liveSubmittedAt,
'live_approved_at' => $liveApprovedAt,
'live_reviewed_at' => $liveReviewedAt,
'live_reviewed_by' => null,
'live_rejection_reason' => null,
// Handle emotion_id: prefer explicit ID, fallback to slug lookup, then default
'emotion_id' => $this->resolveEmotionId($validated, $eventId),