updated table structure for photobooth/sparkbooth settings. now there's a separate table for it. update all references and tests. also fixed the notification panel and the lightbox in the guest app.
This commit is contained in:
@@ -7,13 +7,13 @@ use App\Enums\GuestNotificationDeliveryStatus;
|
||||
use App\Enums\GuestNotificationState;
|
||||
use App\Enums\GuestNotificationType;
|
||||
use App\Events\GuestPhotoUploaded;
|
||||
use App\Jobs\ProcessPhotoSecurityScan;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventJoinToken;
|
||||
use App\Models\EventMediaAsset;
|
||||
use App\Models\GuestNotification;
|
||||
use App\Models\Photo;
|
||||
use App\Models\PhotoShareLink;
|
||||
use App\Jobs\ProcessPhotoSecurityScan;
|
||||
use App\Services\Analytics\JoinTokenAnalyticsRecorder;
|
||||
use App\Services\EventJoinTokenService;
|
||||
use App\Services\EventTasksCacheService;
|
||||
@@ -44,6 +44,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
class EventPublicController extends BaseController
|
||||
{
|
||||
private const SIGNED_URL_TTL_SECONDS = 1800;
|
||||
|
||||
private const BRANDING_SIGNED_TTL_SECONDS = 3600;
|
||||
|
||||
public function __construct(
|
||||
@@ -952,7 +953,7 @@ class EventPublicController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array|mixed> $sources
|
||||
* @param array<int, array|mixed> $sources
|
||||
*/
|
||||
private function firstStringFromSources(array $sources, array $keys): ?string
|
||||
{
|
||||
@@ -969,7 +970,7 @@ class EventPublicController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array|mixed> $sources
|
||||
* @param array<int, array|mixed> $sources
|
||||
*/
|
||||
private function firstNumberFromSources(array $sources, array $keys): ?float
|
||||
{
|
||||
@@ -1778,6 +1779,7 @@ class EventPublicController extends BaseController
|
||||
$branding = $this->buildGalleryBranding($event);
|
||||
$settings = $this->normalizeSettings($event->settings ?? []);
|
||||
$engagementMode = $settings['engagement_mode'] ?? 'tasks';
|
||||
$event->loadMissing('photoboothSetting');
|
||||
|
||||
if ($joinToken) {
|
||||
$this->joinTokenService->incrementUsage($joinToken);
|
||||
@@ -1792,7 +1794,7 @@ class EventPublicController extends BaseController
|
||||
'updated_at' => $event->updated_at,
|
||||
'type' => $eventTypeData,
|
||||
'join_token' => $joinToken?->token,
|
||||
'photobooth_enabled' => (bool) $event->photobooth_enabled,
|
||||
'photobooth_enabled' => (bool) ($event->photoboothSetting?->enabled),
|
||||
'branding' => $branding,
|
||||
'guest_upload_visibility' => Arr::get($event->settings ?? [], 'guest_upload_visibility', 'review'),
|
||||
'engagement_mode' => $engagementMode,
|
||||
@@ -2558,7 +2560,7 @@ class EventPublicController extends BaseController
|
||||
$lastPage = (int) ceil($total / $perPage);
|
||||
$hasMore = $page < $lastPage;
|
||||
|
||||
$etag = sha1($baseHash . ':' . $page . ':' . $perPage . ':' . $seedValue);
|
||||
$etag = sha1($baseHash.':'.$page.':'.$perPage.':'.$seedValue);
|
||||
$reqEtag = $request->headers->get('If-None-Match');
|
||||
|
||||
if ($reqEtag && $reqEtag === $etag) {
|
||||
|
||||
@@ -7,8 +7,8 @@ use App\Models\Event;
|
||||
use App\Services\Photobooth\Exceptions\SparkboothUploadException;
|
||||
use App\Services\Photobooth\SparkboothUploadService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SparkboothUploadController extends Controller
|
||||
@@ -68,7 +68,8 @@ class SparkboothUploadController extends Controller
|
||||
return $preferred;
|
||||
}
|
||||
|
||||
$configured = $event?->photobooth_metadata['sparkbooth_response_format'] ?? null;
|
||||
$event?->loadMissing('photoboothSetting');
|
||||
$configured = ($event?->photoboothSetting?->metadata ?? [])['sparkbooth_response_format'] ?? null;
|
||||
|
||||
if ($configured && in_array($configured, ['json', 'xml'], true)) {
|
||||
return $configured;
|
||||
|
||||
@@ -72,7 +72,7 @@ class PhotoboothController extends Controller
|
||||
protected function resource(Event $event): PhotoboothStatusResource
|
||||
{
|
||||
return PhotoboothStatusResource::make([
|
||||
'event' => $event->fresh(),
|
||||
'event' => $event->fresh('photoboothSetting'),
|
||||
'settings' => PhotoboothSetting::current(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Resources\Tenant;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\EventPhotoboothSetting;
|
||||
use App\Models\PhotoboothSetting;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
@@ -20,31 +21,32 @@ class PhotoboothStatusResource extends JsonResource
|
||||
/** @var PhotoboothSetting $settings */
|
||||
$settings = $payload['settings'];
|
||||
|
||||
$mode = $event->photobooth_mode ?? 'ftp';
|
||||
$event->loadMissing('photoboothSetting');
|
||||
$eventSetting = $event->photoboothSetting;
|
||||
|
||||
$mode = $eventSetting?->mode ?? 'ftp';
|
||||
$isSparkbooth = $mode === 'sparkbooth';
|
||||
|
||||
$password = $isSparkbooth
|
||||
? $event->getAttribute('plain_sparkbooth_password') ?? $event->sparkbooth_password
|
||||
: $event->getAttribute('plain_photobooth_password') ?? $event->photobooth_password;
|
||||
$password = $eventSetting?->getAttribute('plain_password') ?? $eventSetting?->password;
|
||||
|
||||
$activeUsername = $isSparkbooth ? $event->sparkbooth_username : $event->photobooth_username;
|
||||
$activeStatus = $isSparkbooth ? $event->sparkbooth_status : $event->photobooth_status;
|
||||
$activeExpires = $isSparkbooth ? $event->sparkbooth_expires_at : $event->photobooth_expires_at;
|
||||
$activeUsername = $eventSetting?->username;
|
||||
$activeStatus = $eventSetting?->status ?? 'inactive';
|
||||
$activeExpires = $eventSetting?->expires_at;
|
||||
|
||||
$sparkMetrics = [
|
||||
'last_upload_at' => optional($event->sparkbooth_last_upload_at)->toIso8601String(),
|
||||
'uploads_24h' => (int) ($event->sparkbooth_uploads_last_24h ?? 0),
|
||||
'uploads_total' => (int) ($event->sparkbooth_uploads_total ?? 0),
|
||||
'last_upload_at' => optional($eventSetting?->last_upload_at)->toIso8601String(),
|
||||
'uploads_24h' => (int) ($eventSetting?->uploads_last_24h ?? 0),
|
||||
'uploads_total' => (int) ($eventSetting?->uploads_total ?? 0),
|
||||
];
|
||||
|
||||
return [
|
||||
'mode' => $mode,
|
||||
'enabled' => (bool) $event->photobooth_enabled,
|
||||
'enabled' => (bool) ($eventSetting?->enabled),
|
||||
'status' => $activeStatus,
|
||||
'username' => $activeUsername,
|
||||
'password' => $password,
|
||||
'path' => $event->photobooth_path,
|
||||
'ftp_url' => $isSparkbooth ? null : $this->buildFtpUrl($event, $settings, $password),
|
||||
'path' => $eventSetting?->path,
|
||||
'ftp_url' => $isSparkbooth ? null : $this->buildFtpUrl($eventSetting, $settings, $password),
|
||||
'upload_url' => $isSparkbooth ? route('api.v1.photobooth.sparkbooth.upload') : null,
|
||||
'expires_at' => optional($activeExpires)->toIso8601String(),
|
||||
'rate_limit_per_minute' => (int) $settings->rate_limit_per_minute,
|
||||
@@ -55,13 +57,13 @@ class PhotoboothStatusResource extends JsonResource
|
||||
],
|
||||
'metrics' => $isSparkbooth ? $sparkMetrics : null,
|
||||
'sparkbooth' => [
|
||||
'enabled' => $mode === 'sparkbooth' && $event->photobooth_enabled,
|
||||
'status' => $event->sparkbooth_status,
|
||||
'username' => $event->sparkbooth_username,
|
||||
'password' => $event->getAttribute('plain_sparkbooth_password') ?? $event->sparkbooth_password,
|
||||
'expires_at' => optional($event->sparkbooth_expires_at)->toIso8601String(),
|
||||
'enabled' => $mode === 'sparkbooth' && (bool) ($eventSetting?->enabled),
|
||||
'status' => $mode === 'sparkbooth' ? ($eventSetting?->status) : 'inactive',
|
||||
'username' => $mode === 'sparkbooth' ? $eventSetting?->username : null,
|
||||
'password' => $mode === 'sparkbooth' ? $password : null,
|
||||
'expires_at' => $mode === 'sparkbooth' ? optional($eventSetting?->expires_at)->toIso8601String() : null,
|
||||
'upload_url' => route('api.v1.photobooth.sparkbooth.upload'),
|
||||
'response_format' => $event->photobooth_metadata['sparkbooth_response_format'] ?? config('photobooth.sparkbooth.response_format', 'json'),
|
||||
'response_format' => ($eventSetting?->metadata ?? [])['sparkbooth_response_format'] ?? config('photobooth.sparkbooth.response_format', 'json'),
|
||||
'metrics' => $sparkMetrics,
|
||||
],
|
||||
];
|
||||
@@ -87,10 +89,10 @@ class PhotoboothStatusResource extends JsonResource
|
||||
];
|
||||
}
|
||||
|
||||
protected function buildFtpUrl(Event $event, PhotoboothSetting $settings, ?string $password): ?string
|
||||
protected function buildFtpUrl(?EventPhotoboothSetting $eventSetting, PhotoboothSetting $settings, ?string $password): ?string
|
||||
{
|
||||
$host = config('photobooth.ftp.host');
|
||||
$username = $event->photobooth_username;
|
||||
$username = $eventSetting?->username;
|
||||
|
||||
if (! $host || ! $username || ! $password) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user