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:
Codex Agent
2025-12-18 08:49:56 +01:00
parent ece38fc009
commit 1c4acda332
30 changed files with 734 additions and 538 deletions

View File

@@ -2,7 +2,7 @@
namespace App\Console\Commands;
use App\Models\Event;
use App\Models\EventPhotoboothSetting;
use App\Services\Photobooth\PhotoboothProvisioner;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
@@ -17,12 +17,20 @@ class DeactivateExpiredPhotoboothAccounts extends Command
{
$total = 0;
Event::query()
->where('photobooth_enabled', true)
->whereNotNull('photobooth_expires_at')
->where('photobooth_expires_at', '<=', now())
->chunkById(50, function ($events) use (&$total, $provisioner) {
foreach ($events as $event) {
EventPhotoboothSetting::query()
->where('enabled', true)
->where('mode', 'ftp')
->whereNotNull('expires_at')
->where('expires_at', '<=', now())
->with('event')
->chunkById(50, function ($settings) use (&$total, $provisioner) {
foreach ($settings as $setting) {
$event = $setting->event;
if (! $event) {
continue;
}
try {
$provisioner->disable($event);
$total++;

View File

@@ -2,7 +2,7 @@
namespace App\Console\Commands;
use App\Models\Event;
use App\Models\EventPhotoboothSetting;
use App\Services\Photobooth\PhotoboothIngestService;
use Illuminate\Console\Command;
@@ -20,16 +20,23 @@ class PhotoboothIngestCommand extends Command
$processedTotal = 0;
$skippedTotal = 0;
$query = Event::query()
->where('photobooth_enabled', true)
->whereNotNull('photobooth_path');
$query = EventPhotoboothSetting::query()
->where('enabled', true)
->whereNotNull('path')
->with('event');
if ($eventId) {
$query->whereKey($eventId);
$query->where('event_id', $eventId);
}
$query->chunkById(25, function ($settings) use ($ingestService, $maxFiles, &$processedTotal, &$skippedTotal) {
foreach ($settings as $setting) {
$event = $setting->event;
if (! $event) {
continue;
}
$query->chunkById(25, function ($events) use ($ingestService, $maxFiles, &$processedTotal, &$skippedTotal) {
foreach ($events as $event) {
$summary = $ingestService->ingest($event, $maxFiles ? (int) $maxFiles : null);
$processedTotal += $summary['processed'] ?? 0;
$skippedTotal += $summary['skipped'] ?? 0;

View File

@@ -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(
@@ -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) {

View File

@@ -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;

View File

@@ -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(),
]);
}

View File

@@ -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;

View File

@@ -3,13 +3,12 @@
namespace App\Models;
use App\Services\EventJoinTokenService;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Database\Eloquent\Relations\HasOne;
class Event extends Model
{
@@ -24,17 +23,6 @@ class Event extends Model
'is_active' => 'boolean',
'name' => 'array',
'description' => 'array',
'photobooth_enabled' => 'boolean',
'photobooth_mode' => 'string',
'photobooth_expires_at' => 'datetime',
'photobooth_metadata' => 'array',
'sparkbooth_expires_at' => 'datetime',
'sparkbooth_last_upload_at' => 'datetime',
];
protected $hidden = [
'photobooth_password_encrypted',
'sparkbooth_password_encrypted',
];
protected static function booted(): void
@@ -126,6 +114,11 @@ class Event extends Model
return $this->hasMany(EventMember::class);
}
public function photoboothSetting(): HasOne
{
return $this->hasOne(EventPhotoboothSetting::class);
}
public function guestNotifications(): HasMany
{
return $this->hasMany(GuestNotification::class);
@@ -178,48 +171,4 @@ class Event extends Model
$this->attributes['settings'] = json_encode($value ?? []);
}
public function getPhotoboothPasswordAttribute(): ?string
{
$encrypted = $this->attributes['photobooth_password_encrypted'] ?? null;
if (! $encrypted) {
return null;
}
try {
return Crypt::decryptString($encrypted);
} catch (DecryptException) {
return null;
}
}
public function setPhotoboothPasswordAttribute(?string $value): void
{
$this->attributes['photobooth_password_encrypted'] = $value
? Crypt::encryptString($value)
: null;
}
public function getSparkboothPasswordAttribute(): ?string
{
$encrypted = $this->attributes['sparkbooth_password_encrypted'] ?? null;
if (! $encrypted) {
return null;
}
try {
return Crypt::decryptString($encrypted);
} catch (DecryptException) {
return null;
}
}
public function setSparkboothPasswordAttribute(?string $value): void
{
$this->attributes['sparkbooth_password_encrypted'] = $value
? Crypt::encryptString($value)
: null;
}
}

View File

@@ -0,0 +1,64 @@
<?php
namespace App\Models;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Crypt;
class EventPhotoboothSetting extends Model
{
/** @use HasFactory<\Database\Factories\EventPhotoboothSettingFactory> */
use HasFactory;
protected $guarded = [];
protected $casts = [
'enabled' => 'boolean',
'expires_at' => 'datetime',
'last_provisioned_at' => 'datetime',
'last_deprovisioned_at' => 'datetime',
'last_upload_at' => 'datetime',
'metadata' => 'array',
'uploads_last_24h' => 'integer',
'uploads_total' => 'integer',
];
protected $hidden = [
'password_encrypted',
];
public function event(): BelongsTo
{
return $this->belongsTo(Event::class);
}
public function getPasswordAttribute(): ?string
{
$encrypted = $this->attributes['password_encrypted'] ?? null;
if (! $encrypted) {
return null;
}
try {
return Crypt::decryptString($encrypted);
} catch (DecryptException) {
return null;
}
}
public function setPasswordAttribute(?string $value): void
{
$this->attributes['password_encrypted'] = $value
? Crypt::encryptString($value)
: null;
}
public function setUsernameAttribute(?string $value): void
{
$this->attributes['username'] = $value ? strtolower($value) : null;
}
}

View File

@@ -85,9 +85,24 @@ class AccountAnonymizer
'location' => null,
'slug' => 'anonymized-event-'.$event->id,
'status' => 'archived',
'photobooth_enabled' => false,
'photobooth_path' => null,
])->save();
$event->loadMissing('photoboothSetting');
if ($event->photoboothSetting) {
$event->photoboothSetting->forceFill([
'enabled' => false,
'status' => 'inactive',
'username' => null,
'password' => null,
'path' => null,
'expires_at' => null,
'last_deprovisioned_at' => now(),
'last_upload_at' => null,
'uploads_last_24h' => 0,
'uploads_total' => 0,
])->save();
}
}
});

View File

@@ -35,14 +35,16 @@ class PhotoboothIngestService
public function ingest(Event $event, ?int $maxFiles = null, string $ingestSource = Photo::SOURCE_PHOTOBOOTH): array
{
$event->loadMissing('photoboothSetting');
$eventSetting = $event->photoboothSetting;
$tenant = $event->tenant;
if (! $tenant) {
if (! $tenant || ! $eventSetting) {
return ['processed' => 0, 'skipped' => 0];
}
$importDisk = config('photobooth.import.disk', 'photobooth');
$basePath = ltrim((string) $event->photobooth_path, '/');
$basePath = ltrim((string) $eventSetting->path, '/');
if (str_starts_with($basePath, 'photobooth/')) {
$basePath = substr($basePath, strlen('photobooth/'));
}
@@ -178,6 +180,9 @@ class PhotoboothIngestService
$destinationPath,
$thumbnailRelative,
$thumbnailToStore,
$watermarkedPath,
$watermarkedThumb,
$ingestSource,
$mimeType,
$size,
$filename,

View File

@@ -3,6 +3,7 @@
namespace App\Services\Photobooth;
use App\Models\Event;
use App\Models\EventPhotoboothSetting;
use App\Models\PhotoboothSetting;
use Carbon\CarbonInterface;
use Illuminate\Support\Carbon;
@@ -20,9 +21,10 @@ class PhotoboothProvisioner
public function enable(Event $event, ?PhotoboothSetting $settings = null): Event
{
$settings ??= PhotoboothSetting::current();
$event->loadMissing('tenant');
$event->loadMissing(['tenant', 'photoboothSetting']);
return DB::transaction(function () use ($event, $settings) {
$eventSetting = $this->resolveEventSetting($event);
$username = $this->generateUniqueUsername($event, $settings);
$password = $this->credentialGenerator->generatePassword();
$path = $this->buildPath($event);
@@ -39,21 +41,24 @@ class PhotoboothProvisioner
$this->client->provisionUser($payload, $settings);
$event->forceFill([
'photobooth_enabled' => true,
'photobooth_username' => $username,
'photobooth_password' => $password,
'photobooth_path' => $path,
'photobooth_expires_at' => $expiresAt,
'photobooth_status' => 'active',
'photobooth_last_provisioned_at' => now(),
'photobooth_metadata' => [
$eventSetting->forceFill([
'enabled' => true,
'mode' => 'ftp',
'username' => $username,
'password' => $password,
'path' => $path,
'expires_at' => $expiresAt,
'status' => 'active',
'last_provisioned_at' => now(),
'metadata' => [
'rate_limit_per_minute' => $settings->rate_limit_per_minute,
],
])->save();
return tap($event->refresh(), function (Event $refreshed) use ($password) {
$refreshed->setAttribute('plain_photobooth_password', $password);
return tap($event->refresh()->load('photoboothSetting'), function (Event $refreshed) use ($password) {
if ($refreshed->photoboothSetting) {
$refreshed->photoboothSetting->setAttribute('plain_password', $password);
}
});
});
}
@@ -62,11 +67,14 @@ class PhotoboothProvisioner
{
$settings ??= PhotoboothSetting::current();
if (! $event->photobooth_enabled || ! $event->photobooth_username) {
$event->loadMissing('photoboothSetting');
$eventSetting = $event->photoboothSetting;
if (! $eventSetting || ! $eventSetting->enabled || ! $eventSetting->username) {
return $this->enable($event, $settings);
}
return DB::transaction(function () use ($event, $settings) {
return DB::transaction(function () use ($event, $settings, $eventSetting) {
$password = $this->credentialGenerator->generatePassword();
$expiresAt = $this->resolveExpiry($event, $settings);
@@ -76,78 +84,90 @@ class PhotoboothProvisioner
'rate_limit_per_minute' => $settings->rate_limit_per_minute,
];
$this->client->rotateUser($event->photobooth_username, $payload, $settings);
$this->client->rotateUser($eventSetting->username, $payload, $settings);
$event->forceFill([
'photobooth_password' => $password,
'photobooth_expires_at' => $expiresAt,
'photobooth_status' => 'active',
'photobooth_last_provisioned_at' => now(),
$eventSetting->forceFill([
'enabled' => true,
'mode' => 'ftp',
'password' => $password,
'expires_at' => $expiresAt,
'status' => 'active',
'path' => $eventSetting->path ?: $this->buildPath($event),
'last_provisioned_at' => now(),
])->save();
return tap($event->refresh(), function (Event $refreshed) use ($password) {
$refreshed->setAttribute('plain_photobooth_password', $password);
return tap($event->refresh()->load('photoboothSetting'), function (Event $refreshed) use ($password) {
if ($refreshed->photoboothSetting) {
$refreshed->photoboothSetting->setAttribute('plain_password', $password);
}
});
});
}
public function disable(Event $event, ?PhotoboothSetting $settings = null): Event
{
if (! $event->photobooth_username) {
$event->loadMissing('photoboothSetting');
$eventSetting = $event->photoboothSetting;
if (! $eventSetting || ! $eventSetting->username) {
return $event;
}
$settings ??= PhotoboothSetting::current();
return DB::transaction(function () use ($event, $settings) {
return DB::transaction(function () use ($event, $settings, $eventSetting) {
try {
$this->client->deleteUser($event->photobooth_username, $settings);
$this->client->deleteUser($eventSetting->username, $settings);
} catch (\Throwable $exception) {
Log::warning('Photobooth account deletion failed', [
'event_id' => $event->id,
'username' => $event->photobooth_username,
'username' => $eventSetting->username,
'message' => $exception->getMessage(),
]);
}
$event->forceFill([
'photobooth_enabled' => false,
'photobooth_status' => 'inactive',
'photobooth_username' => null,
'photobooth_password' => null,
'photobooth_path' => null,
'photobooth_expires_at' => null,
'photobooth_last_deprovisioned_at' => now(),
$eventSetting->forceFill([
'enabled' => false,
'status' => 'inactive',
'username' => null,
'password' => null,
'path' => null,
'expires_at' => null,
'last_deprovisioned_at' => now(),
])->save();
return $event->refresh();
return $event->refresh()->load('photoboothSetting');
});
}
public function enableSparkbooth(Event $event, ?PhotoboothSetting $settings = null): Event
{
$settings ??= PhotoboothSetting::current();
$event->loadMissing('tenant');
$event->loadMissing(['tenant', 'photoboothSetting']);
return DB::transaction(function () use ($event, $settings) {
$eventSetting = $this->resolveEventSetting($event);
$username = $this->generateUniqueUsername($event, $settings);
$password = $this->credentialGenerator->generatePassword();
$path = $this->buildPath($event);
$expiresAt = $this->resolveExpiry($event, $settings);
$event->forceFill([
'photobooth_enabled' => true,
'photobooth_mode' => 'sparkbooth',
'sparkbooth_username' => $username,
'sparkbooth_password' => $password,
'sparkbooth_expires_at' => $expiresAt,
'sparkbooth_status' => 'active',
'photobooth_path' => $path,
'sparkbooth_uploads_last_24h' => 0,
$eventSetting->forceFill([
'enabled' => true,
'mode' => 'sparkbooth',
'username' => $username,
'password' => $password,
'expires_at' => $expiresAt,
'status' => 'active',
'path' => $path,
'uploads_last_24h' => 0,
'last_provisioned_at' => now(),
])->save();
return tap($event->refresh(), function (Event $refreshed) use ($password) {
$refreshed->setAttribute('plain_sparkbooth_password', $password);
return tap($event->refresh()->load('photoboothSetting'), function (Event $refreshed) use ($password) {
if ($refreshed->photoboothSetting) {
$refreshed->photoboothSetting->setAttribute('plain_password', $password);
}
});
});
}
@@ -155,48 +175,68 @@ class PhotoboothProvisioner
public function rotateSparkbooth(Event $event, ?PhotoboothSetting $settings = null): Event
{
$settings ??= PhotoboothSetting::current();
$event->loadMissing('photoboothSetting');
$eventSetting = $event->photoboothSetting;
if ($event->photobooth_mode !== 'sparkbooth' || ! $event->sparkbooth_username) {
if (! $eventSetting || $eventSetting->mode !== 'sparkbooth' || ! $eventSetting->username) {
return $this->enableSparkbooth($event, $settings);
}
return DB::transaction(function () use ($event, $settings) {
return DB::transaction(function () use ($event, $settings, $eventSetting) {
$password = $this->credentialGenerator->generatePassword();
$expiresAt = $this->resolveExpiry($event, $settings);
$event->forceFill([
'sparkbooth_password' => $password,
'sparkbooth_expires_at' => $expiresAt,
'sparkbooth_status' => 'active',
'photobooth_enabled' => true,
'photobooth_mode' => 'sparkbooth',
$eventSetting->forceFill([
'enabled' => true,
'mode' => 'sparkbooth',
'password' => $password,
'expires_at' => $expiresAt,
'status' => 'active',
'path' => $eventSetting->path ?: $this->buildPath($event),
'last_provisioned_at' => now(),
])->save();
return tap($event->refresh(), function (Event $refreshed) use ($password) {
$refreshed->setAttribute('plain_sparkbooth_password', $password);
return tap($event->refresh()->load('photoboothSetting'), function (Event $refreshed) use ($password) {
if ($refreshed->photoboothSetting) {
$refreshed->photoboothSetting->setAttribute('plain_password', $password);
}
});
});
}
public function disableSparkbooth(Event $event): Event
{
return DB::transaction(function () use ($event) {
$event->forceFill([
'photobooth_enabled' => false,
'photobooth_mode' => 'ftp',
'sparkbooth_username' => null,
'sparkbooth_password' => null,
'sparkbooth_expires_at' => null,
'sparkbooth_status' => 'inactive',
'sparkbooth_last_upload_at' => null,
'sparkbooth_uploads_last_24h' => 0,
'sparkbooth_uploads_total' => 0,
$event->loadMissing('photoboothSetting');
$eventSetting = $event->photoboothSetting;
if (! $eventSetting) {
return $event;
}
return DB::transaction(function () use ($event, $eventSetting) {
$eventSetting->forceFill([
'enabled' => false,
'mode' => 'ftp',
'username' => null,
'password' => null,
'expires_at' => null,
'status' => 'inactive',
'last_upload_at' => null,
'uploads_last_24h' => 0,
'uploads_total' => 0,
])->save();
return $event->refresh();
return $event->refresh()->load('photoboothSetting');
});
}
protected function resolveEventSetting(Event $event): EventPhotoboothSetting
{
$event->loadMissing('photoboothSetting');
return $event->photoboothSetting ?? $event->photoboothSetting()->make();
}
protected function resolveExpiry(Event $event, PhotoboothSetting $settings): CarbonInterface
{
$eventEnd = $event->date ? Carbon::parse($event->date) : now();
@@ -214,14 +254,15 @@ class PhotoboothProvisioner
for ($i = 0; $i < $maxAttempts; $i++) {
$username = $this->credentialGenerator->generateUsername($event);
$exists = Event::query()
->where('photobooth_username', $username)
->orWhere('sparkbooth_username', $username)
->whereKeyNot($event->getKey())
$normalized = strtolower($username);
$exists = EventPhotoboothSetting::query()
->where('username', $normalized)
->where('event_id', '!=', $event->getKey())
->exists();
if (! $exists) {
return strtolower($username);
return $normalized;
}
}

View File

@@ -3,6 +3,7 @@
namespace App\Services\Photobooth;
use App\Models\Event;
use App\Models\EventPhotoboothSetting;
use App\Models\Photo;
use App\Services\Photobooth\Exceptions\SparkboothUploadException;
use Illuminate\Http\UploadedFile;
@@ -21,47 +22,52 @@ class SparkboothUploadService
*/
public function handleUpload(UploadedFile $media, ?string $username, ?string $password): array
{
$event = $this->authenticate($username, $password);
$setting = $this->authenticate($username, $password);
$event = $setting->event;
$this->enforceExpiry($event);
if (! $event) {
throw new SparkboothUploadException('invalid_credentials', 'Invalid credentials', 401);
}
$this->enforceExpiry($setting);
$this->enforceRateLimit($event);
$this->assertValidFile($media);
$importDisk = config('photobooth.import.disk', 'photobooth');
$basePath = ltrim((string) ($event->photobooth_path ?: $this->buildPath($event)), '/');
$basePath = ltrim((string) ($setting->path ?: $this->buildPath($event)), '/');
$extension = strtolower($media->getClientOriginalExtension() ?: $media->extension() ?: 'jpg');
$filename = Str::uuid().'.'.$extension;
$relativePath = "{$basePath}/{$filename}";
if (! $event->photobooth_path) {
$event->forceFill([
'photobooth_path' => $basePath,
if (! $setting->path) {
$setting->forceFill([
'path' => $basePath,
])->save();
}
Storage::disk($importDisk)->makeDirectory($basePath);
Storage::disk($importDisk)->putFileAs($basePath, $media, $filename);
$summary = $this->ingestService->ingest($event->fresh(), 1, Photo::SOURCE_SPARKBOOTH);
$summary = $this->ingestService->ingest($event->fresh('photoboothSetting'), 1, Photo::SOURCE_SPARKBOOTH);
if (($summary['processed'] ?? 0) < 1) {
throw new SparkboothUploadException('ingest_failed', 'Upload failed, please retry.', 500);
}
$event->forceFill([
'sparkbooth_last_upload_at' => now(),
'sparkbooth_uploads_last_24h' => ($event->sparkbooth_uploads_last_24h ?? 0) + 1,
'sparkbooth_uploads_total' => ($event->sparkbooth_uploads_total ?? 0) + 1,
$setting->forceFill([
'last_upload_at' => now(),
'uploads_last_24h' => ($setting->uploads_last_24h ?? 0) + 1,
'uploads_total' => ($setting->uploads_total ?? 0) + 1,
])->save();
return [
'event' => $event->fresh(),
'event' => $event->fresh('photoboothSetting'),
'processed' => $summary['processed'] ?? 0,
'skipped' => $summary['skipped'] ?? 0,
];
}
protected function authenticate(?string $username, ?string $password): Event
protected function authenticate(?string $username, ?string $password): EventPhotoboothSetting
{
if (! $username || ! $password) {
throw new SparkboothUploadException('missing_credentials', 'Invalid credentials', 401);
@@ -69,29 +75,34 @@ class SparkboothUploadService
$normalizedUsername = strtolower(trim($username));
/** @var Event|null $event */
$event = Event::query()
->whereRaw('LOWER(sparkbooth_username) = ?', [$normalizedUsername])
/** @var EventPhotoboothSetting|null $setting */
$setting = EventPhotoboothSetting::query()
->where('username', $normalizedUsername)
->with('event')
->first();
if (! $event) {
if (! $setting) {
throw new SparkboothUploadException('invalid_credentials', 'Invalid credentials', 401);
}
if ($event->photobooth_mode !== 'sparkbooth' || ! $event->photobooth_enabled) {
if (! $setting->event) {
throw new SparkboothUploadException('invalid_credentials', 'Invalid credentials', 401);
}
if ($setting->mode !== 'sparkbooth' || ! $setting->enabled) {
throw new SparkboothUploadException('disabled', 'Upload not active for this event', 403);
}
if (! hash_equals($event->sparkbooth_password ?? '', $password ?? '')) {
if (! hash_equals($setting->password ?? '', $password ?? '')) {
throw new SparkboothUploadException('invalid_credentials', 'Invalid credentials', 401);
}
return $event;
return $setting;
}
protected function enforceExpiry(Event $event): void
protected function enforceExpiry(EventPhotoboothSetting $setting): void
{
if ($event->sparkbooth_expires_at && $event->sparkbooth_expires_at->isPast()) {
if ($setting->expires_at && $setting->expires_at->isPast()) {
throw new SparkboothUploadException('expired', 'Upload access has expired', 403);
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace Database\Factories;
use App\Models\Event;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\EventPhotoboothSetting>
*/
class EventPhotoboothSettingFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'event_id' => Event::factory(),
'enabled' => false,
'mode' => 'ftp',
'status' => 'inactive',
'uploads_last_24h' => 0,
'uploads_total' => 0,
];
}
public function activeFtp(): static
{
return $this->state(fn () => [
'enabled' => true,
'mode' => 'ftp',
'status' => 'active',
]);
}
public function activeSparkbooth(): static
{
return $this->state(fn () => [
'enabled' => true,
'mode' => 'sparkbooth',
'status' => 'active',
]);
}
}

View File

@@ -1,46 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('events', function (Blueprint $table) {
$table->boolean('photobooth_enabled')->default(false)->after('settings');
$table->string('photobooth_username', 32)->nullable()->after('photobooth_enabled');
$table->text('photobooth_password_encrypted')->nullable()->after('photobooth_username');
$table->string('photobooth_path')->nullable()->after('photobooth_password_encrypted');
$table->timestamp('photobooth_expires_at')->nullable()->after('photobooth_path');
$table->string('photobooth_status', 32)->default('inactive')->after('photobooth_expires_at');
$table->timestamp('photobooth_last_provisioned_at')->nullable()->after('photobooth_status');
$table->timestamp('photobooth_last_deprovisioned_at')->nullable()->after('photobooth_last_provisioned_at');
$table->json('photobooth_metadata')->nullable()->after('photobooth_last_deprovisioned_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropColumn([
'photobooth_enabled',
'photobooth_username',
'photobooth_password_encrypted',
'photobooth_path',
'photobooth_expires_at',
'photobooth_status',
'photobooth_last_provisioned_at',
'photobooth_last_deprovisioned_at',
'photobooth_metadata',
]);
});
}
};

View File

@@ -16,8 +16,8 @@ return new class extends Migration
$table->json('settings')->nullable()->after('max_participants');
}
$table->boolean('watermark_serve_originals')->default(false)->after('photobooth_metadata');
$table->json('watermark_settings')->nullable()->after('photobooth_metadata');
$table->boolean('watermark_serve_originals')->default(false)->after('settings');
$table->json('watermark_settings')->nullable()->after('watermark_serve_originals');
});
}

View File

@@ -1,59 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('events', function (Blueprint $table) {
$table->string('photobooth_mode', 16)
->default('ftp')
->after('photobooth_enabled');
$table->string('sparkbooth_username', 32)
->nullable()
->after('photobooth_path');
$table->text('sparkbooth_password_encrypted')
->nullable()
->after('sparkbooth_username');
$table->timestamp('sparkbooth_expires_at')
->nullable()
->after('sparkbooth_password_encrypted');
$table->string('sparkbooth_status', 32)
->default('inactive')
->after('sparkbooth_expires_at');
$table->timestamp('sparkbooth_last_upload_at')
->nullable()
->after('sparkbooth_status');
$table->unsignedInteger('sparkbooth_uploads_last_24h')
->default(0)
->after('sparkbooth_last_upload_at');
$table->unsignedBigInteger('sparkbooth_uploads_total')
->default(0)
->after('sparkbooth_uploads_last_24h');
$table->unique('sparkbooth_username');
});
}
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropUnique(['sparkbooth_username']);
$table->dropColumn([
'photobooth_mode',
'sparkbooth_username',
'sparkbooth_password_encrypted',
'sparkbooth_expires_at',
'sparkbooth_status',
'sparkbooth_last_upload_at',
'sparkbooth_uploads_last_24h',
'sparkbooth_uploads_total',
]);
});
}
};

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('event_photobooth_settings', function (Blueprint $table) {
$table->id();
$table->foreignId('event_id')->constrained()->cascadeOnDelete();
$table->boolean('enabled')->default(false);
$table->string('mode', 16)->default('ftp');
$table->string('username', 32)->nullable();
$table->text('password_encrypted')->nullable();
$table->string('path')->nullable();
$table->string('status', 32)->default('inactive');
$table->timestamp('expires_at')->nullable();
$table->timestamp('last_provisioned_at')->nullable();
$table->timestamp('last_deprovisioned_at')->nullable();
$table->timestamp('last_upload_at')->nullable();
$table->unsignedInteger('uploads_last_24h')->default(0);
$table->unsignedBigInteger('uploads_total')->default(0);
$table->json('metadata')->nullable();
$table->timestamps();
$table->unique('event_id');
$table->unique('username');
$table->index(['enabled', 'expires_at']);
$table->index(['enabled', 'path']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('event_photobooth_settings');
}
};

View File

@@ -22,7 +22,7 @@ class DatabaseSeeder extends Seeder
EventTypesSeeder::class,
EmotionsSeeder::class,
TaskCollectionsSeeder::class,
InviteLayoutSeeder::class,
]);
$this->call([

View File

@@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use App\Models\EventPhotoboothSetting;
use Illuminate\Database\Seeder;
class EventPhotoboothSettingSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
EventPhotoboothSetting::factory()->create();
}
}

View File

@@ -56,7 +56,7 @@ export default function GalleryPreview({ token }: Props) {
arr.sort((a, b) => new Date(b.created_at ?? 0).getTime() - new Date(a.created_at ?? 0).getTime());
}
return arr.slice(0, 4); // 2x2 = 4 items
return arr.slice(0, 9); // up to 3x3 preview
}, [typedPhotos, mode]);
React.useEffect(() => {
@@ -134,7 +134,7 @@ export default function GalleryPreview({ token }: Props) {
</div>
)}
<div className="grid gap-2 sm:grid-cols-2">
<div className="grid gap-2 grid-cols-2 md:grid-cols-3">
{items.map((p: PreviewPhoto) => (
<Link
key={p.id}

View File

@@ -149,7 +149,6 @@ export default function Header({ eventToken, title = '' }: { eventToken?: string
const { event, status } = useEventData();
const notificationCenter = useOptionalNotificationCenter();
const [notificationsOpen, setNotificationsOpen] = React.useState(false);
const [statusFilter, setStatusFilter] = React.useState<'new' | 'read' | 'dismissed' | 'all'>('new');
const taskProgress = useGuestTaskProgress(eventToken);
const tasksEnabled = isTaskModeEnabled(event);
const panelRef = React.useRef<HTMLDivElement | null>(null);
@@ -275,8 +274,7 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
? Math.min(1, taskProgress.completedCount / TASK_BADGE_TARGET)
: 0;
const [activeTab, setActiveTab] = React.useState<'unread' | 'all' | 'status'>(center.unreadCount > 0 ? 'unread' : 'all');
const [statusFilter, setStatusFilter] = React.useState<'new' | 'read' | 'dismissed' | 'all'>('new');
const [scopeFilter, setScopeFilter] = React.useState<'all' | 'uploads' | 'tips' | 'general'>('all');
const [scopeFilter, setScopeFilter] = React.useState<'all' | 'tips' | 'general'>('all');
const pushState = usePushSubscription(eventToken);
React.useEffect(() => {
@@ -306,19 +304,14 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
default:
base = center.notifications;
}
if (statusFilter === 'all') return base;
return base.filter((item) => item.status === (statusFilter === 'new' ? 'new' : statusFilter));
}, [activeTab, center.notifications, unreadNotifications, uploadNotifications, statusFilter]);
return base;
}, [activeTab, center.notifications, unreadNotifications, uploadNotifications]);
const scopedNotifications = React.useMemo(() => {
if (scopeFilter === 'all') {
return filteredNotifications;
}
return filteredNotifications.filter((item) => {
if (scopeFilter === 'uploads') {
return item.type === 'upload_alert' || item.type === 'photo_activity';
}
if (scopeFilter === 'tips') {
return item.type === 'support_tip' || item.type === 'achievement_major';
}
@@ -332,7 +325,7 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
type="button"
onClick={onToggle}
className="relative rounded-full bg-white/15 p-2 text-white transition hover:bg-white/30"
aria-label={t('header.notifications.open', 'Benachrichtigungen anzeigen')}
aria-label={open ? t('header.notifications.close', 'Benachrichtigungen schließen') : t('header.notifications.open', 'Benachrichtigungen anzeigen')}
>
<Bell className="h-5 w-5" aria-hidden />
{badgeCount > 0 && (
@@ -374,46 +367,33 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
activeTab={activeTab}
onTabChange={(next) => setActiveTab(next as typeof activeTab)}
/>
<div className="mt-2">
<label className="sr-only" htmlFor="notification-scope">
{t('header.notifications.scopeLabel', 'Bereich filtern')}
</label>
<select
id="notification-scope"
value={scopeFilter}
onChange={(event) => {
const next = event.target.value as typeof scopeFilter;
setScopeFilter(next);
notificationCenter?.setFilters({ scope: next, status: statusFilter });
<div className="mt-3">
<div className="flex gap-2 overflow-x-auto text-xs whitespace-nowrap pb-1">
{(
[
{ key: 'all', label: t('header.notifications.scope.all', 'Alle') },
{ key: 'tips', label: t('header.notifications.scope.tips', 'Tipps & Achievements') },
{ key: 'general', label: t('header.notifications.scope.general', 'Allgemein') },
] as const
).map((option) => (
<button
key={option.key}
type="button"
onClick={() => {
setScopeFilter(option.key);
center.setFilters({ scope: option.key });
}}
className="w-full rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 shadow-sm"
className={`rounded-full border px-3 py-1 font-semibold transition ${
scopeFilter === option.key
? 'border-pink-200 bg-pink-50 text-pink-700'
: 'border-slate-200 bg-white text-slate-600 hover:border-pink-200 hover:text-pink-700'
}`}
>
<option value="all">{t('header.notifications.scope.all', 'Alle')}</option>
<option value="uploads">{t('header.notifications.scope.uploads', 'Uploads/Status')}</option>
<option value="tips">{t('header.notifications.scope.tips', 'Tipps & Achievements')}</option>
<option value="general">{t('header.notifications.scope.general', 'Allgemein')}</option>
</select>
<select
value={statusFilter}
onChange={(event) => {
const value = event.target.value as typeof statusFilter;
setStatusFilter(value);
notificationCenter?.setFilters({ status: value, scope: scopeFilter });
}}
className="mt-2 w-full rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 shadow-sm"
>
<option value="new">{t('header.notifications.filter.unread', 'Neu')}</option>
<option value="read">{t('header.notifications.filter.read', 'Gelesen')}</option>
<option value="dismissed">{t('header.notifications.filter.dismissed', 'Ausgeblendet')}</option>
<option value="all">{t('header.notifications.filter.all', 'Alle')}</option>
</select>
{option.label}
</button>
))}
</div>
</div>
<NotificationStatusBar
lastFetchedAt={center.lastFetchedAt}
isOffline={center.isOffline}
push={pushState}
t={t}
/>
<div className="mt-3 max-h-80 space-y-2 overflow-y-auto pr-1">
{center.loading ? (
<NotificationSkeleton />
@@ -440,26 +420,27 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
))
)}
</div>
<div className="mt-4 rounded-2xl border border-slate-200 bg-slate-50/80 p-3">
<div className="flex items-center justify-between text-sm">
<span className="text-slate-600">
{t('header.notifications.queueLabel', 'Uploads in Warteschlange')}
</span>
{activeTab === 'status' && (
<div className="mt-3 flex items-center justify-between rounded-xl bg-slate-50/90 px-3 py-2 text-xs text-slate-600">
<div className="flex items-center gap-2">
<UploadCloud className="h-4 w-4 text-slate-400" aria-hidden />
<span>{t('header.notifications.queueLabel', 'Uploads in Warteschlange')}</span>
<span className="font-semibold text-slate-900">{center.queueCount}</span>
</div>
<Link
to={`/e/${encodeURIComponent(eventToken)}/queue`}
className="mt-2 inline-flex items-center gap-1 text-sm font-semibold text-pink-600"
className="inline-flex items-center gap-1 font-semibold text-pink-600"
onClick={() => {
if (center.unreadCount > 0) {
void center.refresh();
}
}}
>
{t('header.notifications.queueCta', 'Upload-Verlauf öffnen')}
{t('header.notifications.queueCta', 'Verlauf')}
<ArrowUpRight className="h-4 w-4" aria-hidden />
</Link>
</div>
)}
{taskProgress && (
<div className="mt-3 rounded-2xl border border-slate-200 bg-slate-50/90 p-3">
<div className="flex items-center justify-between">
@@ -484,6 +465,12 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
</div>
</div>
)}
<NotificationStatusBar
lastFetchedAt={center.lastFetchedAt}
isOffline={center.isOffline}
push={pushState}
t={t}
/>
</div>,
typeof document !== 'undefined' ? document.body : undefined
)}
@@ -719,7 +706,7 @@ function NotificationStatusBar({
const pushButtonDisabled = push.loading || !push.supported || push.permission === 'denied';
return (
<div className="mt-2 space-y-2 text-[11px] text-slate-500">
<div className="mt-4 space-y-2 border-t border-slate-200 pt-3 text-[11px] text-slate-500">
<div className="flex items-center justify-between">
<span>
{t('header.notifications.lastSync', 'Zuletzt aktualisiert')}: {label}

View File

@@ -322,7 +322,7 @@ export default function GalleryPage() {
styleOverride={{ borderRadius: radius, fontFamily: headingFont }}
/>
{loading && <p className="px-4" style={bodyFont ? { fontFamily: bodyFont } : undefined}>{t('galleryPage.loading', 'Lade…')}</p>}
<div className="grid grid-cols-3 gap-2 px-4 pb-16 sm:grid-cols-3 md:grid-cols-4">
<div className="grid grid-cols-2 gap-2 px-2 pb-16 sm:grid-cols-3 lg:grid-cols-4">
{list.map((p: GalleryPhoto) => {
const imageUrl = normalizeImageUrl(p.thumbnail_path || p.file_path);
const createdLabel = p.created_at
@@ -371,13 +371,6 @@ export default function GalleryPage() {
<span className="ml-3 truncate text-right">{p.uploader_name || t('galleryPage.photo.anonymous', 'Gast')}</span>
</div>
</div>
<div className="absolute left-3 top-3 z-10 flex flex-col items-start gap-2">
{localizedTaskTitle && (
<span className="rounded-full bg-white/20 px-3 py-1 text-[11px] font-semibold uppercase tracking-wide text-white shadow" style={{ borderRadius: radius }}>
{localizedTaskTitle}
</span>
)}
</div>
<div className="absolute right-3 top-3 z-10 flex items-center gap-2">
<button
type="button"

View File

@@ -279,13 +279,17 @@ export default function HomePage() {
introArray.push(candidate);
}
}
const introMessage =
const introMessageRef = React.useRef<string | null>(null);
if (!introMessageRef.current) {
introMessageRef.current =
introArray.length > 0 ? introArray[Math.floor(Math.random() * introArray.length)] : '';
}
const introMessage = introMessageRef.current;
if (!tasksEnabled) {
return (
<div className="space-y-3 pb-24" style={bodyFont ? { fontFamily: bodyFont } : undefined}>
<section className="space-y-1 px-4">
<section className="space-y-1 px-4" style={headingFont ? { fontFamily: headingFont } : undefined}>
<p className="text-sm font-semibold text-foreground">
{t('home.welcomeLine').replace('{name}', displayName)}
</p>
@@ -312,7 +316,7 @@ export default function HomePage() {
return (
<div className="space-y-0.5 pb-24" style={bodyFont ? { fontFamily: bodyFont } : undefined}>
<section className="space-y-1 px-4">
<section className="space-y-1 px-4" style={headingFont ? { fontFamily: headingFont } : undefined}>
<p className="text-sm font-semibold text-foreground">
{t('home.welcomeLine').replace('{name}', displayName)}
</p>
@@ -476,12 +480,13 @@ function MissionActionCard({
const bodyFont = branding.typography?.body ?? branding.fontFamily ?? undefined;
const cards = mission ? [mission, ...stack] : stack;
const shellRadius = `${radius + 10}px`;
const normalizeText = (value: string | undefined | null) =>
(value ?? '').trim().toLowerCase().replace(/\s+/g, ' ');
const renderCardContent = (card: MissionPreview | null) => {
const theme = getEmotionTheme(card?.emotion ?? null);
const emotionIcon = getEmotionIcon(card?.emotion ?? null);
const durationMinutes = card?.duration ?? 3;
const progressValue = Math.min(100, Math.max(20, (durationMinutes / 8) * 100));
const titleFont = headingFont ? { fontFamily: headingFont } : undefined;
const gradientBackground = card ? theme.gradientBackground : `linear-gradient(135deg, ${primary}, ${secondary})`;
@@ -524,7 +529,7 @@ function MissionActionCard({
</Badge>
<div className="flex items-center gap-2 text-xs font-medium text-slate-600">
<Sparkles className="h-4 w-4 text-amber-500" aria-hidden />
<span>Deine nächste Foto-Aufgabe wartet</span>
<span>Foto-Challenge</span>
</div>
</div>
</div>
@@ -538,7 +543,7 @@ function MissionActionCard({
<div className="mt-4 text-center">
{card ? (
<p
className="text-2xl font-semibold leading-tight text-slate-900 line-clamp-2"
className="text-2xl font-semibold leading-tight text-slate-900 line-clamp-3 min-h-[3.5rem] py-1"
style={{ ...titleFont, textShadow: '0 6px 18px rgba(15,23,42,0.28)' }}
>
{card.title}
@@ -554,16 +559,18 @@ function MissionActionCard({
)}
</div>
{card?.description && normalizeText(card.title) !== normalizeText(card.description) ? (
<div className="mt-4 space-y-2">
<Progress
value={card ? progressValue : 35}
className="h-2 overflow-hidden bg-white/70"
/>
<div className="flex items-center justify-between text-[11px] font-semibold uppercase tracking-wide text-slate-500">
<span>Mission bereit</span>
<span>{card ? 'Tippe zum Start' : 'Neue Mission lädt'}</span>
<div className="flex items-center justify-between">
<div className="space-y-1 text-left">
<p className="text-sm font-semibold text-slate-800" style={titleFont}>
{card.title}
</p>
<p className="text-sm leading-relaxed text-slate-600">{card.description}</p>
</div>
</div>
</div>
) : null}
<div className="mt-4 grid grid-cols-[2fr_1fr] gap-2">
<Button

View File

@@ -2,7 +2,9 @@ import React, { useState, useEffect } from 'react';
import { useParams, useLocation, useNavigate } from 'react-router-dom';
import { Dialog, DialogContent } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Heart, ChevronLeft, ChevronRight, X, Share2 } from 'lucide-react';
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { Badge } from '@/components/ui/badge';
import { Heart, ChevronLeft, ChevronRight, X, Share2, Download } from 'lucide-react';
import { likePhoto, createPhotoShareLink } from '../services/photosApi';
import { useTranslation } from '../i18n/useTranslation';
import { useToast } from '../components/ToastHost';
@@ -18,6 +20,7 @@ type Photo = {
created_at?: string;
task_id?: number;
task_title?: string;
uploader_name?: string | null;
};
type Task = { id: number; title: string };
@@ -230,6 +233,24 @@ export default function PhotoLightbox({ photos, currentIndex, onClose, onIndexCh
const shareTitle = photo?.task_title ?? task?.title ?? t('share.title', 'Geteiltes Foto');
const shareText = t('share.shareText', { event: eventName ?? shareTitle ?? 'Fotospiel' });
const createdLabel = React.useMemo(() => {
if (!photo?.created_at) return null;
try {
const date = new Date(photo.created_at);
return date.toLocaleString(locale, { dateStyle: 'medium', timeStyle: 'short' });
} catch {
return null;
}
}, [photo?.created_at, locale]);
const uploaderInitial = React.useMemo(() => {
const name = photo?.uploader_name;
if (!name) return 'G';
return (name.trim()[0] || 'G').toUpperCase();
}, [photo?.uploader_name]);
const primaryColor = branding.primaryColor || '#0ea5e9';
const secondaryColor = branding.secondaryColor || '#6366f1';
async function openShareSheet() {
if (!photo || !eventToken) return;
@@ -295,81 +316,56 @@ export default function PhotoLightbox({ photos, currentIndex, onClose, onIndexCh
return (
<Dialog open={true} onOpenChange={onOpenChange}>
<DialogContent hideClose className="max-w-5xl border-0 bg-black p-0 text-white">
{/* Header with controls */}
<div className="flex items-center justify-between p-2">
<div className="flex items-center gap-2">
<Button
variant="secondary"
size="sm"
onClick={onLike}
disabled={liked}
<DialogContent
hideClose
className="max-w-6xl overflow-hidden rounded-3xl border border-white/10 bg-white/5 p-0 text-white shadow-2xl backdrop-blur-3xl"
>
<Heart className={`mr-1 h-4 w-4 ${liked ? 'fill-red-400 text-red-400' : ''}`} />
{likes}
<div className="relative">
<div className="absolute inset-0 opacity-50" style={{ background: 'radial-gradient(circle at 20% 20%, rgba(255,255,255,0.12), transparent 40%), radial-gradient(circle at 80% 10%, rgba(255,255,255,0.1), transparent 35%)' }} />
<div className="absolute top-4 left-0 right-0 z-30 flex items-center justify-between px-5">
<div className="flex items-center gap-2 rounded-full border border-white/20 bg-black/40 px-2 py-1 shadow-lg backdrop-blur">
<Button variant="ghost" size="icon" onClick={onClose} className="h-10 w-10 rounded-full text-white hover:bg-white/10">
<X className="h-5 w-5" />
</Button>
<div className="rounded-full bg-white/10 px-3 py-1 text-xs font-semibold text-white/90">
{currentIndexVal + 1} / {currentPhotos.length}
</div>
</div>
<div className="flex items-center gap-2 rounded-full border border-white/20 bg-black/40 px-2 py-1 shadow-lg backdrop-blur">
<Button variant="ghost" size="icon" onClick={onLike} disabled={liked} className="h-10 w-10 rounded-full text-white hover:bg-white/10">
<Heart className={`h-5 w-5 ${liked ? 'fill-red-500 text-red-500' : ''}`} />
</Button>
<Button
variant="secondary"
size="sm"
variant="ghost"
size="icon"
onClick={openShareSheet}
disabled={!eventToken || !photo}
className="h-10 w-10 rounded-full text-white hover:bg-white/10"
>
<Share2 className="mr-1 h-4 w-4" />
{t('share.button', 'Teilen')}
<Share2 className="h-5 w-5" />
</Button>
</div>
<div className="flex items-center gap-1">
{currentIndexVal > 0 && (
<Button
variant="ghost"
size="sm"
onClick={() => onIndexChange?.(currentIndexVal - 1)}
className="h-8 w-8 p-0"
>
<ChevronLeft className="h-4 w-4" />
</Button>
)}
<Button
variant="ghost"
size="sm"
onClick={onClose}
className="h-8 w-8 p-0"
>
<X className="h-4 w-4" />
</Button>
{currentIndexVal < currentPhotos.length - 1 && (
<Button
variant="ghost"
size="sm"
onClick={() => onIndexChange?.(currentIndexVal + 1)}
className="h-8 w-8 p-0"
>
<ChevronRight className="h-4 w-4" />
</Button>
)}
</div>
</div>
{/* Task Info Overlay */}
{task && (
<div className="absolute bottom-4 left-4 right-4 z-20 bg-black/60 backdrop-blur-sm rounded-xl p-3 border border-white/20 max-w-md">
<div className="text-sm">
<div className="font-semibold mb-1 text-white">{t('lightbox.taskLabel')}: {task.title}</div>
{taskLoading && (
<div className="text-xs opacity-70 text-gray-300">{t('lightbox.loadingTask')}</div>
)}
</div>
</div>
)}
{/* Photo Display */}
<div className="px-3 pb-5 pt-16">
<div
ref={touchRef}
className="flex items-center justify-center min-h-[60vh] p-4 relative overflow-hidden"
className="relative flex min-h-[60vh] items-center justify-center overflow-hidden rounded-[30px] border border-white/15 bg-black/30 p-4 shadow-xl backdrop-blur"
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}
>
{currentIndexVal > 0 && (
<Button
variant="ghost"
size="icon"
onClick={() => onIndexChange?.(currentIndexVal - 1)}
className="absolute left-3 top-1/2 -translate-y-1/2 rounded-full bg-white/90 text-slate-800 shadow-lg hover:bg-white"
>
<ChevronLeft className="h-5 w-5" />
</Button>
)}
<img
src={photo?.file_path || photo?.thumbnail_path}
alt={t('lightbox.photoAlt')
@@ -380,23 +376,90 @@ export default function PhotoLightbox({ photos, currentIndex, onClose, onIndexCh
? t('lightbox.photoAltTaskSuffix').replace('{taskTitle}', photo.task_title)
: ''
)}
className="max-h-[80vh] max-w-full object-contain transition-transform duration-200"
className="max-h-[70vh] max-w-full object-contain transition-transform duration-200"
onError={(e) => {
console.error('Image load error:', e);
(e.target as HTMLImageElement).style.display = 'none';
}}
/>
{currentIndexVal < currentPhotos.length - 1 && (
<Button
variant="ghost"
size="icon"
onClick={() => onIndexChange?.(currentIndexVal + 1)}
className="absolute right-3 top-1/2 -translate-y-1/2 rounded-full bg-white/90 text-slate-800 shadow-lg hover:bg-white"
>
<ChevronRight className="h-5 w-5" />
</Button>
)}
</div>
{/* Loading state for task */}
{taskLoading && !task && (
<div className="absolute top-4 left-4 right-4 z-20 bg-black/60 backdrop-blur-sm rounded-xl p-3 border border-white/20 max-w-md">
<div className="text-sm text-center">
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mx-auto mb-1"></div>
<div className="text-xs opacity-70">{t('lightbox.loadingTask')}</div>
<div className="mt-5 grid gap-3 rounded-2xl border border-white/15 bg-black/35 px-4 py-3 text-sm text-white/90 shadow-md backdrop-blur sm:grid-cols-[1.3fr_1fr]">
<div className="flex items-center gap-3">
<Avatar className="h-11 w-11 border border-white/20 bg-white/10">
<AvatarFallback className="text-white">{uploaderInitial}</AvatarFallback>
</Avatar>
<div className="space-y-1">
{photo?.uploader_name ? (
<p className="font-semibold text-white">{photo.uploader_name}</p>
) : (
<p className="font-semibold text-white">{t('galleryPage.photo.anonymous', 'Gast')}</p>
)}
{createdLabel ? <p className="text-xs text-white/70">{createdLabel}</p> : null}
</div>
</div>
<div className="flex flex-wrap items-center justify-start gap-2 sm:justify-end">
{task ? (
<Badge variant="outline" className="border-white/30 bg-white/10 text-white">
{t('lightbox.taskLabel')}: {task.title}
</Badge>
) : null}
<div className="flex items-center gap-2">
<Button
variant="ghost"
size="icon"
onClick={onLike}
disabled={liked}
className="h-9 w-9 rounded-full text-white hover:bg-white/10"
aria-label={t('lightbox.like', 'Like photo')}
>
<Heart className={`h-5 w-5 ${liked ? 'fill-red-500 text-red-500' : ''}`} />
</Button>
<Button
variant="ghost"
size="icon"
onClick={openShareSheet}
disabled={!eventToken || !photo}
className="h-9 w-9 rounded-full text-white hover:bg-white/10"
aria-label={t('share.button', 'Teilen')}
>
<Share2 className="h-5 w-5" />
</Button>
<Button
variant="ghost"
size="icon"
onClick={() => {
if (!photo?.file_path) return;
window.open(photo.file_path, '_blank', 'noopener');
}}
className="h-9 w-9 rounded-full text-white hover:bg-white/10"
aria-label={t('lightbox.download', 'Download')}
disabled={!photo?.file_path}
>
<Download className="h-5 w-5" />
</Button>
</div>
</div>
</div>
{taskLoading && !task && (
<div className="mt-4 rounded-xl border border-white/20 bg-black/40 p-3 text-center text-xs text-white/80 shadow-sm backdrop-blur">
<div className="mx-auto mb-1 h-4 w-4 animate-spin rounded-full border-b-2 border-white/70" />
{t('lightbox.loadingTask')}
</div>
)}
</div>
</div>
<ShareSheet
open={shareSheet.loading || Boolean(shareSheet.url)}

View File

@@ -124,7 +124,6 @@ export default function UploadPage() {
const { t, locale } = useTranslation();
const stats = useEventStats();
const { branding } = useEventBranding();
const { event } = useEventData();
const radius = branding.buttons?.radius ?? 12;
const buttonStyle = branding.buttons?.style ?? 'filled';
const linkColor = branding.buttons?.linkColor ?? branding.secondaryColor;

View File

@@ -1,7 +1,14 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import type { LocaleCode } from '../i18n/messages';
type Photo = { id: number; file_path?: string; thumbnail_path?: string; created_at?: string; session_id?: string | null };
type Photo = {
id: number;
file_path?: string;
thumbnail_path?: string;
created_at?: string;
session_id?: string | null;
uploader_name?: string | null;
};
type RawPhoto = Record<string, unknown>;
export function usePollGalleryDelta(token: string, locale: LocaleCode) {
@@ -60,6 +67,12 @@ export function usePollGalleryDelta(token: string, locale: LocaleCode) {
const newPhotos: Photo[] = rawPhotos.map((photo: RawPhoto) => ({
...(photo as Photo),
session_id: typeof photo.session_id === 'string' ? photo.session_id : (photo.guest_name as string | null) ?? null,
uploader_name:
typeof photo.uploader_name === 'string'
? (photo.uploader_name as string)
: typeof photo.guest_name === 'string'
? (photo.guest_name as string)
: null,
}));
if (newPhotos.length > 0) {

View File

@@ -3,6 +3,7 @@
namespace Tests\Feature\Console;
use App\Models\Event;
use App\Models\EventPhotoboothSetting;
use App\Models\PhotoboothSetting;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
@@ -23,15 +24,18 @@ class PhotoboothCleanupCommandTest extends TestCase
'control_service_base_url' => 'https://control.test',
]);
$event = Event::factory()->create([
'photobooth_enabled' => true,
'photobooth_username' => 'pbcleanup',
'photobooth_status' => 'active',
'photobooth_path' => '/photobooth/demo',
'photobooth_expires_at' => now()->subDay(),
$event = Event::factory()->create();
$setting = EventPhotoboothSetting::factory()
->for($event)
->create([
'enabled' => true,
'mode' => 'ftp',
'username' => 'pbcleanup',
'password' => 'CLEANUP',
'status' => 'active',
'path' => '/photobooth/demo',
'expires_at' => now()->subDay(),
]);
$event->photobooth_password = 'CLEANUP';
$event->save();
Http::fake([
'https://control.test/*' => Http::response(['ok' => true], 200),
@@ -40,11 +44,11 @@ class PhotoboothCleanupCommandTest extends TestCase
$this->artisan('photobooth:cleanup-expired')
->assertExitCode(0);
$event->refresh();
$setting->refresh();
$this->assertFalse($event->photobooth_enabled);
$this->assertNull($event->photobooth_username);
$this->assertNotNull($event->photobooth_last_deprovisioned_at);
$this->assertFalse($setting->enabled);
$this->assertNull($setting->username);
$this->assertNotNull($setting->last_deprovisioned_at);
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users/pbcleanup');
}

View File

@@ -3,6 +3,7 @@
namespace Tests\Feature\Photobooth;
use App\Models\Event;
use App\Models\EventPhotoboothSetting;
use App\Models\PhotoboothSetting;
use Illuminate\Support\Facades\Http;
use PHPUnit\Framework\Attributes\Test;
@@ -58,11 +59,13 @@ class PhotoboothControllerTest extends TenantTestCase
->assertJsonPath('data.username', fn ($value) => is_string($value) && strlen($value) <= 10);
$event->refresh();
$this->assertTrue($event->photobooth_enabled);
$this->assertNotNull($event->photobooth_username);
$this->assertNotNull($event->photobooth_password);
$username = $event->photobooth_username;
$firstPassword = $event->photobooth_password;
$setting = $event->photoboothSetting;
$this->assertNotNull($setting);
$this->assertTrue($setting->enabled);
$this->assertNotNull($setting->username);
$this->assertNotNull($setting->password);
$username = $setting->username;
$firstPassword = $setting->password;
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users' && $request['username'] === $username);
@@ -72,7 +75,7 @@ class PhotoboothControllerTest extends TenantTestCase
->assertJsonPath('data.enabled', true);
$event->refresh();
$this->assertNotSame($firstPassword, $event->photobooth_password);
$this->assertNotSame($firstPassword, $event->photoboothSetting?->password);
Http::assertSent(fn ($request) => $request->url() === "https://control.test/users/{$username}/rotate");
}
@@ -82,14 +85,18 @@ class PhotoboothControllerTest extends TenantTestCase
{
$event = Event::factory()->for($this->tenant)->create([
'slug' => 'photobooth-disable',
'photobooth_enabled' => true,
'photobooth_username' => 'pb123456',
'photobooth_path' => '/photobooth/demo',
'photobooth_status' => 'active',
'photobooth_expires_at' => now()->subDay(),
]);
$event->photobooth_password = 'SECRET12';
$event->save();
EventPhotoboothSetting::factory()
->for($event)
->create([
'enabled' => true,
'mode' => 'ftp',
'username' => 'pb123456',
'password' => 'SECRET12',
'path' => '/photobooth/demo',
'status' => 'active',
'expires_at' => now()->subDay(),
]);
Http::fake([
'https://control.test/*' => Http::response(['ok' => true], 200),
@@ -102,8 +109,8 @@ class PhotoboothControllerTest extends TenantTestCase
->assertJsonPath('data.username', null);
$event->refresh();
$this->assertFalse($event->photobooth_enabled);
$this->assertNull($event->photobooth_username);
$this->assertFalse($event->photoboothSetting?->enabled);
$this->assertNull($event->photoboothSetting?->username);
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users/pb123456');
}

View File

@@ -3,6 +3,7 @@
namespace Tests\Feature\Photobooth;
use App\Models\Event;
use App\Models\EventPhotoboothSetting;
use App\Models\Photo;
use App\Models\Tenant;
use App\Services\EventJoinTokenService;
@@ -22,18 +23,25 @@ class PhotoboothFilterTest extends TestCase
->for($tenant)
->create([
'status' => 'published',
'photobooth_enabled' => true,
]);
EventPhotoboothSetting::factory()
->for($event)
->create([
'enabled' => true,
'mode' => 'ftp',
]);
Photo::factory()->create([
'event_id' => $event->id,
'ingest_source' => Photo::SOURCE_PHOTOBOOTH,
'guest_name' => Photo::SOURCE_PHOTOBOOTH,
'status' => 'approved',
]);
Photo::factory()->create([
'event_id' => $event->id,
'ingest_source' => Photo::SOURCE_GUEST_PWA,
'status' => 'approved',
]);
/** @var EventJoinTokenService $tokens */

View File

@@ -6,6 +6,7 @@ use App\Jobs\ProcessPhotoSecurityScan;
use App\Models\Emotion;
use App\Models\Event;
use App\Models\EventPackage;
use App\Models\EventPhotoboothSetting;
use App\Models\MediaStorageTarget;
use App\Models\Package;
use App\Models\Photo;
@@ -53,11 +54,14 @@ class PhotoboothIngestCommandTest extends TestCase
->create([
'slug' => 'demo-event',
'status' => 'published',
'photobooth_enabled' => true,
]);
$event->update([
'photobooth_path' => $tenant->slug.'/'.$event->id,
$setting = EventPhotoboothSetting::factory()
->for($event)
->create([
'enabled' => true,
'mode' => 'ftp',
'path' => $tenant->slug.'/'.$event->id,
]);
$package = Package::factory()->create(['max_photos' => 5]);
@@ -68,7 +72,8 @@ class PhotoboothIngestCommandTest extends TestCase
'used_photos' => 0,
]);
Storage::disk('photobooth')->put($event->photobooth_path.'/sample.jpg', $this->sampleImage());
Storage::disk('photobooth')->makeDirectory($setting->path);
Storage::disk('photobooth')->put($setting->path.'/sample.jpg', $this->sampleImage());
Emotion::factory()->create();
Bus::fake();
@@ -81,7 +86,7 @@ class PhotoboothIngestCommandTest extends TestCase
'ingest_source' => Photo::SOURCE_PHOTOBOOTH,
]);
Storage::disk('photobooth')->assertMissing($event->photobooth_path.'/sample.jpg');
Storage::disk('photobooth')->assertMissing($setting->path.'/sample.jpg');
Bus::assertDispatched(ProcessPhotoSecurityScan::class);
}