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:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\Event;
|
use App\Models\EventPhotoboothSetting;
|
||||||
use App\Services\Photobooth\PhotoboothProvisioner;
|
use App\Services\Photobooth\PhotoboothProvisioner;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@@ -17,12 +17,20 @@ class DeactivateExpiredPhotoboothAccounts extends Command
|
|||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
|
|
||||||
Event::query()
|
EventPhotoboothSetting::query()
|
||||||
->where('photobooth_enabled', true)
|
->where('enabled', true)
|
||||||
->whereNotNull('photobooth_expires_at')
|
->where('mode', 'ftp')
|
||||||
->where('photobooth_expires_at', '<=', now())
|
->whereNotNull('expires_at')
|
||||||
->chunkById(50, function ($events) use (&$total, $provisioner) {
|
->where('expires_at', '<=', now())
|
||||||
foreach ($events as $event) {
|
->with('event')
|
||||||
|
->chunkById(50, function ($settings) use (&$total, $provisioner) {
|
||||||
|
foreach ($settings as $setting) {
|
||||||
|
$event = $setting->event;
|
||||||
|
|
||||||
|
if (! $event) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$provisioner->disable($event);
|
$provisioner->disable($event);
|
||||||
$total++;
|
$total++;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\Event;
|
use App\Models\EventPhotoboothSetting;
|
||||||
use App\Services\Photobooth\PhotoboothIngestService;
|
use App\Services\Photobooth\PhotoboothIngestService;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
@@ -20,16 +20,23 @@ class PhotoboothIngestCommand extends Command
|
|||||||
$processedTotal = 0;
|
$processedTotal = 0;
|
||||||
$skippedTotal = 0;
|
$skippedTotal = 0;
|
||||||
|
|
||||||
$query = Event::query()
|
$query = EventPhotoboothSetting::query()
|
||||||
->where('photobooth_enabled', true)
|
->where('enabled', true)
|
||||||
->whereNotNull('photobooth_path');
|
->whereNotNull('path')
|
||||||
|
->with('event');
|
||||||
|
|
||||||
if ($eventId) {
|
if ($eventId) {
|
||||||
$query->whereKey($eventId);
|
$query->where('event_id', $eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query->chunkById(25, function ($events) use ($ingestService, $maxFiles, &$processedTotal, &$skippedTotal) {
|
$query->chunkById(25, function ($settings) use ($ingestService, $maxFiles, &$processedTotal, &$skippedTotal) {
|
||||||
foreach ($events as $event) {
|
foreach ($settings as $setting) {
|
||||||
|
$event = $setting->event;
|
||||||
|
|
||||||
|
if (! $event) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$summary = $ingestService->ingest($event, $maxFiles ? (int) $maxFiles : null);
|
$summary = $ingestService->ingest($event, $maxFiles ? (int) $maxFiles : null);
|
||||||
$processedTotal += $summary['processed'] ?? 0;
|
$processedTotal += $summary['processed'] ?? 0;
|
||||||
$skippedTotal += $summary['skipped'] ?? 0;
|
$skippedTotal += $summary['skipped'] ?? 0;
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ use App\Enums\GuestNotificationDeliveryStatus;
|
|||||||
use App\Enums\GuestNotificationState;
|
use App\Enums\GuestNotificationState;
|
||||||
use App\Enums\GuestNotificationType;
|
use App\Enums\GuestNotificationType;
|
||||||
use App\Events\GuestPhotoUploaded;
|
use App\Events\GuestPhotoUploaded;
|
||||||
|
use App\Jobs\ProcessPhotoSecurityScan;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
use App\Models\EventJoinToken;
|
use App\Models\EventJoinToken;
|
||||||
use App\Models\EventMediaAsset;
|
use App\Models\EventMediaAsset;
|
||||||
use App\Models\GuestNotification;
|
use App\Models\GuestNotification;
|
||||||
use App\Models\Photo;
|
use App\Models\Photo;
|
||||||
use App\Models\PhotoShareLink;
|
use App\Models\PhotoShareLink;
|
||||||
use App\Jobs\ProcessPhotoSecurityScan;
|
|
||||||
use App\Services\Analytics\JoinTokenAnalyticsRecorder;
|
use App\Services\Analytics\JoinTokenAnalyticsRecorder;
|
||||||
use App\Services\EventJoinTokenService;
|
use App\Services\EventJoinTokenService;
|
||||||
use App\Services\EventTasksCacheService;
|
use App\Services\EventTasksCacheService;
|
||||||
@@ -44,6 +44,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
class EventPublicController extends BaseController
|
class EventPublicController extends BaseController
|
||||||
{
|
{
|
||||||
private const SIGNED_URL_TTL_SECONDS = 1800;
|
private const SIGNED_URL_TTL_SECONDS = 1800;
|
||||||
|
|
||||||
private const BRANDING_SIGNED_TTL_SECONDS = 3600;
|
private const BRANDING_SIGNED_TTL_SECONDS = 3600;
|
||||||
|
|
||||||
public function __construct(
|
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
|
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
|
private function firstNumberFromSources(array $sources, array $keys): ?float
|
||||||
{
|
{
|
||||||
@@ -1778,6 +1779,7 @@ class EventPublicController extends BaseController
|
|||||||
$branding = $this->buildGalleryBranding($event);
|
$branding = $this->buildGalleryBranding($event);
|
||||||
$settings = $this->normalizeSettings($event->settings ?? []);
|
$settings = $this->normalizeSettings($event->settings ?? []);
|
||||||
$engagementMode = $settings['engagement_mode'] ?? 'tasks';
|
$engagementMode = $settings['engagement_mode'] ?? 'tasks';
|
||||||
|
$event->loadMissing('photoboothSetting');
|
||||||
|
|
||||||
if ($joinToken) {
|
if ($joinToken) {
|
||||||
$this->joinTokenService->incrementUsage($joinToken);
|
$this->joinTokenService->incrementUsage($joinToken);
|
||||||
@@ -1792,7 +1794,7 @@ class EventPublicController extends BaseController
|
|||||||
'updated_at' => $event->updated_at,
|
'updated_at' => $event->updated_at,
|
||||||
'type' => $eventTypeData,
|
'type' => $eventTypeData,
|
||||||
'join_token' => $joinToken?->token,
|
'join_token' => $joinToken?->token,
|
||||||
'photobooth_enabled' => (bool) $event->photobooth_enabled,
|
'photobooth_enabled' => (bool) ($event->photoboothSetting?->enabled),
|
||||||
'branding' => $branding,
|
'branding' => $branding,
|
||||||
'guest_upload_visibility' => Arr::get($event->settings ?? [], 'guest_upload_visibility', 'review'),
|
'guest_upload_visibility' => Arr::get($event->settings ?? [], 'guest_upload_visibility', 'review'),
|
||||||
'engagement_mode' => $engagementMode,
|
'engagement_mode' => $engagementMode,
|
||||||
@@ -2558,7 +2560,7 @@ class EventPublicController extends BaseController
|
|||||||
$lastPage = (int) ceil($total / $perPage);
|
$lastPage = (int) ceil($total / $perPage);
|
||||||
$hasMore = $page < $lastPage;
|
$hasMore = $page < $lastPage;
|
||||||
|
|
||||||
$etag = sha1($baseHash . ':' . $page . ':' . $perPage . ':' . $seedValue);
|
$etag = sha1($baseHash.':'.$page.':'.$perPage.':'.$seedValue);
|
||||||
$reqEtag = $request->headers->get('If-None-Match');
|
$reqEtag = $request->headers->get('If-None-Match');
|
||||||
|
|
||||||
if ($reqEtag && $reqEtag === $etag) {
|
if ($reqEtag && $reqEtag === $etag) {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ use App\Models\Event;
|
|||||||
use App\Services\Photobooth\Exceptions\SparkboothUploadException;
|
use App\Services\Photobooth\Exceptions\SparkboothUploadException;
|
||||||
use App\Services\Photobooth\SparkboothUploadService;
|
use App\Services\Photobooth\SparkboothUploadService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\UploadedFile;
|
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class SparkboothUploadController extends Controller
|
class SparkboothUploadController extends Controller
|
||||||
@@ -68,7 +68,8 @@ class SparkboothUploadController extends Controller
|
|||||||
return $preferred;
|
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)) {
|
if ($configured && in_array($configured, ['json', 'xml'], true)) {
|
||||||
return $configured;
|
return $configured;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class PhotoboothController extends Controller
|
|||||||
protected function resource(Event $event): PhotoboothStatusResource
|
protected function resource(Event $event): PhotoboothStatusResource
|
||||||
{
|
{
|
||||||
return PhotoboothStatusResource::make([
|
return PhotoboothStatusResource::make([
|
||||||
'event' => $event->fresh(),
|
'event' => $event->fresh('photoboothSetting'),
|
||||||
'settings' => PhotoboothSetting::current(),
|
'settings' => PhotoboothSetting::current(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Resources\Tenant;
|
namespace App\Http\Resources\Tenant;
|
||||||
|
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
|
use App\Models\EventPhotoboothSetting;
|
||||||
use App\Models\PhotoboothSetting;
|
use App\Models\PhotoboothSetting;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
@@ -20,31 +21,32 @@ class PhotoboothStatusResource extends JsonResource
|
|||||||
/** @var PhotoboothSetting $settings */
|
/** @var PhotoboothSetting $settings */
|
||||||
$settings = $payload['settings'];
|
$settings = $payload['settings'];
|
||||||
|
|
||||||
$mode = $event->photobooth_mode ?? 'ftp';
|
$event->loadMissing('photoboothSetting');
|
||||||
|
$eventSetting = $event->photoboothSetting;
|
||||||
|
|
||||||
|
$mode = $eventSetting?->mode ?? 'ftp';
|
||||||
$isSparkbooth = $mode === 'sparkbooth';
|
$isSparkbooth = $mode === 'sparkbooth';
|
||||||
|
|
||||||
$password = $isSparkbooth
|
$password = $eventSetting?->getAttribute('plain_password') ?? $eventSetting?->password;
|
||||||
? $event->getAttribute('plain_sparkbooth_password') ?? $event->sparkbooth_password
|
|
||||||
: $event->getAttribute('plain_photobooth_password') ?? $event->photobooth_password;
|
|
||||||
|
|
||||||
$activeUsername = $isSparkbooth ? $event->sparkbooth_username : $event->photobooth_username;
|
$activeUsername = $eventSetting?->username;
|
||||||
$activeStatus = $isSparkbooth ? $event->sparkbooth_status : $event->photobooth_status;
|
$activeStatus = $eventSetting?->status ?? 'inactive';
|
||||||
$activeExpires = $isSparkbooth ? $event->sparkbooth_expires_at : $event->photobooth_expires_at;
|
$activeExpires = $eventSetting?->expires_at;
|
||||||
|
|
||||||
$sparkMetrics = [
|
$sparkMetrics = [
|
||||||
'last_upload_at' => optional($event->sparkbooth_last_upload_at)->toIso8601String(),
|
'last_upload_at' => optional($eventSetting?->last_upload_at)->toIso8601String(),
|
||||||
'uploads_24h' => (int) ($event->sparkbooth_uploads_last_24h ?? 0),
|
'uploads_24h' => (int) ($eventSetting?->uploads_last_24h ?? 0),
|
||||||
'uploads_total' => (int) ($event->sparkbooth_uploads_total ?? 0),
|
'uploads_total' => (int) ($eventSetting?->uploads_total ?? 0),
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'mode' => $mode,
|
'mode' => $mode,
|
||||||
'enabled' => (bool) $event->photobooth_enabled,
|
'enabled' => (bool) ($eventSetting?->enabled),
|
||||||
'status' => $activeStatus,
|
'status' => $activeStatus,
|
||||||
'username' => $activeUsername,
|
'username' => $activeUsername,
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
'path' => $event->photobooth_path,
|
'path' => $eventSetting?->path,
|
||||||
'ftp_url' => $isSparkbooth ? null : $this->buildFtpUrl($event, $settings, $password),
|
'ftp_url' => $isSparkbooth ? null : $this->buildFtpUrl($eventSetting, $settings, $password),
|
||||||
'upload_url' => $isSparkbooth ? route('api.v1.photobooth.sparkbooth.upload') : null,
|
'upload_url' => $isSparkbooth ? route('api.v1.photobooth.sparkbooth.upload') : null,
|
||||||
'expires_at' => optional($activeExpires)->toIso8601String(),
|
'expires_at' => optional($activeExpires)->toIso8601String(),
|
||||||
'rate_limit_per_minute' => (int) $settings->rate_limit_per_minute,
|
'rate_limit_per_minute' => (int) $settings->rate_limit_per_minute,
|
||||||
@@ -55,13 +57,13 @@ class PhotoboothStatusResource extends JsonResource
|
|||||||
],
|
],
|
||||||
'metrics' => $isSparkbooth ? $sparkMetrics : null,
|
'metrics' => $isSparkbooth ? $sparkMetrics : null,
|
||||||
'sparkbooth' => [
|
'sparkbooth' => [
|
||||||
'enabled' => $mode === 'sparkbooth' && $event->photobooth_enabled,
|
'enabled' => $mode === 'sparkbooth' && (bool) ($eventSetting?->enabled),
|
||||||
'status' => $event->sparkbooth_status,
|
'status' => $mode === 'sparkbooth' ? ($eventSetting?->status) : 'inactive',
|
||||||
'username' => $event->sparkbooth_username,
|
'username' => $mode === 'sparkbooth' ? $eventSetting?->username : null,
|
||||||
'password' => $event->getAttribute('plain_sparkbooth_password') ?? $event->sparkbooth_password,
|
'password' => $mode === 'sparkbooth' ? $password : null,
|
||||||
'expires_at' => optional($event->sparkbooth_expires_at)->toIso8601String(),
|
'expires_at' => $mode === 'sparkbooth' ? optional($eventSetting?->expires_at)->toIso8601String() : null,
|
||||||
'upload_url' => route('api.v1.photobooth.sparkbooth.upload'),
|
'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,
|
'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');
|
$host = config('photobooth.ftp.host');
|
||||||
$username = $event->photobooth_username;
|
$username = $eventSetting?->username;
|
||||||
|
|
||||||
if (! $host || ! $username || ! $password) {
|
if (! $host || ! $username || ! $password) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -3,13 +3,12 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Services\EventJoinTokenService;
|
use App\Services\EventJoinTokenService;
|
||||||
use Illuminate\Contracts\Encryption\DecryptException;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
|
||||||
class Event extends Model
|
class Event extends Model
|
||||||
{
|
{
|
||||||
@@ -24,17 +23,6 @@ class Event extends Model
|
|||||||
'is_active' => 'boolean',
|
'is_active' => 'boolean',
|
||||||
'name' => 'array',
|
'name' => 'array',
|
||||||
'description' => '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
|
protected static function booted(): void
|
||||||
@@ -126,6 +114,11 @@ class Event extends Model
|
|||||||
return $this->hasMany(EventMember::class);
|
return $this->hasMany(EventMember::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function photoboothSetting(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(EventPhotoboothSetting::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function guestNotifications(): HasMany
|
public function guestNotifications(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(GuestNotification::class);
|
return $this->hasMany(GuestNotification::class);
|
||||||
@@ -178,48 +171,4 @@ class Event extends Model
|
|||||||
|
|
||||||
$this->attributes['settings'] = json_encode($value ?? []);
|
$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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
64
app/Models/EventPhotoboothSetting.php
Normal file
64
app/Models/EventPhotoboothSetting.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -85,9 +85,24 @@ class AccountAnonymizer
|
|||||||
'location' => null,
|
'location' => null,
|
||||||
'slug' => 'anonymized-event-'.$event->id,
|
'slug' => 'anonymized-event-'.$event->id,
|
||||||
'status' => 'archived',
|
'status' => 'archived',
|
||||||
'photobooth_enabled' => false,
|
|
||||||
'photobooth_path' => null,
|
|
||||||
])->save();
|
])->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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -35,14 +35,16 @@ class PhotoboothIngestService
|
|||||||
|
|
||||||
public function ingest(Event $event, ?int $maxFiles = null, string $ingestSource = Photo::SOURCE_PHOTOBOOTH): array
|
public function ingest(Event $event, ?int $maxFiles = null, string $ingestSource = Photo::SOURCE_PHOTOBOOTH): array
|
||||||
{
|
{
|
||||||
|
$event->loadMissing('photoboothSetting');
|
||||||
|
$eventSetting = $event->photoboothSetting;
|
||||||
$tenant = $event->tenant;
|
$tenant = $event->tenant;
|
||||||
|
|
||||||
if (! $tenant) {
|
if (! $tenant || ! $eventSetting) {
|
||||||
return ['processed' => 0, 'skipped' => 0];
|
return ['processed' => 0, 'skipped' => 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$importDisk = config('photobooth.import.disk', 'photobooth');
|
$importDisk = config('photobooth.import.disk', 'photobooth');
|
||||||
$basePath = ltrim((string) $event->photobooth_path, '/');
|
$basePath = ltrim((string) $eventSetting->path, '/');
|
||||||
if (str_starts_with($basePath, 'photobooth/')) {
|
if (str_starts_with($basePath, 'photobooth/')) {
|
||||||
$basePath = substr($basePath, strlen('photobooth/'));
|
$basePath = substr($basePath, strlen('photobooth/'));
|
||||||
}
|
}
|
||||||
@@ -178,6 +180,9 @@ class PhotoboothIngestService
|
|||||||
$destinationPath,
|
$destinationPath,
|
||||||
$thumbnailRelative,
|
$thumbnailRelative,
|
||||||
$thumbnailToStore,
|
$thumbnailToStore,
|
||||||
|
$watermarkedPath,
|
||||||
|
$watermarkedThumb,
|
||||||
|
$ingestSource,
|
||||||
$mimeType,
|
$mimeType,
|
||||||
$size,
|
$size,
|
||||||
$filename,
|
$filename,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Services\Photobooth;
|
namespace App\Services\Photobooth;
|
||||||
|
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
|
use App\Models\EventPhotoboothSetting;
|
||||||
use App\Models\PhotoboothSetting;
|
use App\Models\PhotoboothSetting;
|
||||||
use Carbon\CarbonInterface;
|
use Carbon\CarbonInterface;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
@@ -20,9 +21,10 @@ class PhotoboothProvisioner
|
|||||||
public function enable(Event $event, ?PhotoboothSetting $settings = null): Event
|
public function enable(Event $event, ?PhotoboothSetting $settings = null): Event
|
||||||
{
|
{
|
||||||
$settings ??= PhotoboothSetting::current();
|
$settings ??= PhotoboothSetting::current();
|
||||||
$event->loadMissing('tenant');
|
$event->loadMissing(['tenant', 'photoboothSetting']);
|
||||||
|
|
||||||
return DB::transaction(function () use ($event, $settings) {
|
return DB::transaction(function () use ($event, $settings) {
|
||||||
|
$eventSetting = $this->resolveEventSetting($event);
|
||||||
$username = $this->generateUniqueUsername($event, $settings);
|
$username = $this->generateUniqueUsername($event, $settings);
|
||||||
$password = $this->credentialGenerator->generatePassword();
|
$password = $this->credentialGenerator->generatePassword();
|
||||||
$path = $this->buildPath($event);
|
$path = $this->buildPath($event);
|
||||||
@@ -39,21 +41,24 @@ class PhotoboothProvisioner
|
|||||||
|
|
||||||
$this->client->provisionUser($payload, $settings);
|
$this->client->provisionUser($payload, $settings);
|
||||||
|
|
||||||
$event->forceFill([
|
$eventSetting->forceFill([
|
||||||
'photobooth_enabled' => true,
|
'enabled' => true,
|
||||||
'photobooth_username' => $username,
|
'mode' => 'ftp',
|
||||||
'photobooth_password' => $password,
|
'username' => $username,
|
||||||
'photobooth_path' => $path,
|
'password' => $password,
|
||||||
'photobooth_expires_at' => $expiresAt,
|
'path' => $path,
|
||||||
'photobooth_status' => 'active',
|
'expires_at' => $expiresAt,
|
||||||
'photobooth_last_provisioned_at' => now(),
|
'status' => 'active',
|
||||||
'photobooth_metadata' => [
|
'last_provisioned_at' => now(),
|
||||||
|
'metadata' => [
|
||||||
'rate_limit_per_minute' => $settings->rate_limit_per_minute,
|
'rate_limit_per_minute' => $settings->rate_limit_per_minute,
|
||||||
],
|
],
|
||||||
])->save();
|
])->save();
|
||||||
|
|
||||||
return tap($event->refresh(), function (Event $refreshed) use ($password) {
|
return tap($event->refresh()->load('photoboothSetting'), function (Event $refreshed) use ($password) {
|
||||||
$refreshed->setAttribute('plain_photobooth_password', $password);
|
if ($refreshed->photoboothSetting) {
|
||||||
|
$refreshed->photoboothSetting->setAttribute('plain_password', $password);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -62,11 +67,14 @@ class PhotoboothProvisioner
|
|||||||
{
|
{
|
||||||
$settings ??= PhotoboothSetting::current();
|
$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 $this->enable($event, $settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DB::transaction(function () use ($event, $settings) {
|
return DB::transaction(function () use ($event, $settings, $eventSetting) {
|
||||||
$password = $this->credentialGenerator->generatePassword();
|
$password = $this->credentialGenerator->generatePassword();
|
||||||
$expiresAt = $this->resolveExpiry($event, $settings);
|
$expiresAt = $this->resolveExpiry($event, $settings);
|
||||||
|
|
||||||
@@ -76,78 +84,90 @@ class PhotoboothProvisioner
|
|||||||
'rate_limit_per_minute' => $settings->rate_limit_per_minute,
|
'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([
|
$eventSetting->forceFill([
|
||||||
'photobooth_password' => $password,
|
'enabled' => true,
|
||||||
'photobooth_expires_at' => $expiresAt,
|
'mode' => 'ftp',
|
||||||
'photobooth_status' => 'active',
|
'password' => $password,
|
||||||
'photobooth_last_provisioned_at' => now(),
|
'expires_at' => $expiresAt,
|
||||||
|
'status' => 'active',
|
||||||
|
'path' => $eventSetting->path ?: $this->buildPath($event),
|
||||||
|
'last_provisioned_at' => now(),
|
||||||
])->save();
|
])->save();
|
||||||
|
|
||||||
return tap($event->refresh(), function (Event $refreshed) use ($password) {
|
return tap($event->refresh()->load('photoboothSetting'), function (Event $refreshed) use ($password) {
|
||||||
$refreshed->setAttribute('plain_photobooth_password', $password);
|
if ($refreshed->photoboothSetting) {
|
||||||
|
$refreshed->photoboothSetting->setAttribute('plain_password', $password);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable(Event $event, ?PhotoboothSetting $settings = null): Event
|
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;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
$settings ??= PhotoboothSetting::current();
|
$settings ??= PhotoboothSetting::current();
|
||||||
|
|
||||||
return DB::transaction(function () use ($event, $settings) {
|
return DB::transaction(function () use ($event, $settings, $eventSetting) {
|
||||||
try {
|
try {
|
||||||
$this->client->deleteUser($event->photobooth_username, $settings);
|
$this->client->deleteUser($eventSetting->username, $settings);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
Log::warning('Photobooth account deletion failed', [
|
Log::warning('Photobooth account deletion failed', [
|
||||||
'event_id' => $event->id,
|
'event_id' => $event->id,
|
||||||
'username' => $event->photobooth_username,
|
'username' => $eventSetting->username,
|
||||||
'message' => $exception->getMessage(),
|
'message' => $exception->getMessage(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$event->forceFill([
|
$eventSetting->forceFill([
|
||||||
'photobooth_enabled' => false,
|
'enabled' => false,
|
||||||
'photobooth_status' => 'inactive',
|
'status' => 'inactive',
|
||||||
'photobooth_username' => null,
|
'username' => null,
|
||||||
'photobooth_password' => null,
|
'password' => null,
|
||||||
'photobooth_path' => null,
|
'path' => null,
|
||||||
'photobooth_expires_at' => null,
|
'expires_at' => null,
|
||||||
'photobooth_last_deprovisioned_at' => now(),
|
'last_deprovisioned_at' => now(),
|
||||||
])->save();
|
])->save();
|
||||||
|
|
||||||
return $event->refresh();
|
return $event->refresh()->load('photoboothSetting');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function enableSparkbooth(Event $event, ?PhotoboothSetting $settings = null): Event
|
public function enableSparkbooth(Event $event, ?PhotoboothSetting $settings = null): Event
|
||||||
{
|
{
|
||||||
$settings ??= PhotoboothSetting::current();
|
$settings ??= PhotoboothSetting::current();
|
||||||
$event->loadMissing('tenant');
|
$event->loadMissing(['tenant', 'photoboothSetting']);
|
||||||
|
|
||||||
return DB::transaction(function () use ($event, $settings) {
|
return DB::transaction(function () use ($event, $settings) {
|
||||||
|
$eventSetting = $this->resolveEventSetting($event);
|
||||||
$username = $this->generateUniqueUsername($event, $settings);
|
$username = $this->generateUniqueUsername($event, $settings);
|
||||||
$password = $this->credentialGenerator->generatePassword();
|
$password = $this->credentialGenerator->generatePassword();
|
||||||
$path = $this->buildPath($event);
|
$path = $this->buildPath($event);
|
||||||
$expiresAt = $this->resolveExpiry($event, $settings);
|
$expiresAt = $this->resolveExpiry($event, $settings);
|
||||||
|
|
||||||
$event->forceFill([
|
$eventSetting->forceFill([
|
||||||
'photobooth_enabled' => true,
|
'enabled' => true,
|
||||||
'photobooth_mode' => 'sparkbooth',
|
'mode' => 'sparkbooth',
|
||||||
'sparkbooth_username' => $username,
|
'username' => $username,
|
||||||
'sparkbooth_password' => $password,
|
'password' => $password,
|
||||||
'sparkbooth_expires_at' => $expiresAt,
|
'expires_at' => $expiresAt,
|
||||||
'sparkbooth_status' => 'active',
|
'status' => 'active',
|
||||||
'photobooth_path' => $path,
|
'path' => $path,
|
||||||
'sparkbooth_uploads_last_24h' => 0,
|
'uploads_last_24h' => 0,
|
||||||
|
'last_provisioned_at' => now(),
|
||||||
])->save();
|
])->save();
|
||||||
|
|
||||||
return tap($event->refresh(), function (Event $refreshed) use ($password) {
|
return tap($event->refresh()->load('photoboothSetting'), function (Event $refreshed) use ($password) {
|
||||||
$refreshed->setAttribute('plain_sparkbooth_password', $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
|
public function rotateSparkbooth(Event $event, ?PhotoboothSetting $settings = null): Event
|
||||||
{
|
{
|
||||||
$settings ??= PhotoboothSetting::current();
|
$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 $this->enableSparkbooth($event, $settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DB::transaction(function () use ($event, $settings) {
|
return DB::transaction(function () use ($event, $settings, $eventSetting) {
|
||||||
$password = $this->credentialGenerator->generatePassword();
|
$password = $this->credentialGenerator->generatePassword();
|
||||||
$expiresAt = $this->resolveExpiry($event, $settings);
|
$expiresAt = $this->resolveExpiry($event, $settings);
|
||||||
|
|
||||||
$event->forceFill([
|
$eventSetting->forceFill([
|
||||||
'sparkbooth_password' => $password,
|
'enabled' => true,
|
||||||
'sparkbooth_expires_at' => $expiresAt,
|
'mode' => 'sparkbooth',
|
||||||
'sparkbooth_status' => 'active',
|
'password' => $password,
|
||||||
'photobooth_enabled' => true,
|
'expires_at' => $expiresAt,
|
||||||
'photobooth_mode' => 'sparkbooth',
|
'status' => 'active',
|
||||||
|
'path' => $eventSetting->path ?: $this->buildPath($event),
|
||||||
|
'last_provisioned_at' => now(),
|
||||||
])->save();
|
])->save();
|
||||||
|
|
||||||
return tap($event->refresh(), function (Event $refreshed) use ($password) {
|
return tap($event->refresh()->load('photoboothSetting'), function (Event $refreshed) use ($password) {
|
||||||
$refreshed->setAttribute('plain_sparkbooth_password', $password);
|
if ($refreshed->photoboothSetting) {
|
||||||
|
$refreshed->photoboothSetting->setAttribute('plain_password', $password);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disableSparkbooth(Event $event): Event
|
public function disableSparkbooth(Event $event): Event
|
||||||
{
|
{
|
||||||
return DB::transaction(function () use ($event) {
|
$event->loadMissing('photoboothSetting');
|
||||||
$event->forceFill([
|
$eventSetting = $event->photoboothSetting;
|
||||||
'photobooth_enabled' => false,
|
|
||||||
'photobooth_mode' => 'ftp',
|
if (! $eventSetting) {
|
||||||
'sparkbooth_username' => null,
|
return $event;
|
||||||
'sparkbooth_password' => null,
|
}
|
||||||
'sparkbooth_expires_at' => null,
|
|
||||||
'sparkbooth_status' => 'inactive',
|
return DB::transaction(function () use ($event, $eventSetting) {
|
||||||
'sparkbooth_last_upload_at' => null,
|
$eventSetting->forceFill([
|
||||||
'sparkbooth_uploads_last_24h' => 0,
|
'enabled' => false,
|
||||||
'sparkbooth_uploads_total' => 0,
|
'mode' => 'ftp',
|
||||||
|
'username' => null,
|
||||||
|
'password' => null,
|
||||||
|
'expires_at' => null,
|
||||||
|
'status' => 'inactive',
|
||||||
|
'last_upload_at' => null,
|
||||||
|
'uploads_last_24h' => 0,
|
||||||
|
'uploads_total' => 0,
|
||||||
])->save();
|
])->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
|
protected function resolveExpiry(Event $event, PhotoboothSetting $settings): CarbonInterface
|
||||||
{
|
{
|
||||||
$eventEnd = $event->date ? Carbon::parse($event->date) : now();
|
$eventEnd = $event->date ? Carbon::parse($event->date) : now();
|
||||||
@@ -214,14 +254,15 @@ class PhotoboothProvisioner
|
|||||||
for ($i = 0; $i < $maxAttempts; $i++) {
|
for ($i = 0; $i < $maxAttempts; $i++) {
|
||||||
$username = $this->credentialGenerator->generateUsername($event);
|
$username = $this->credentialGenerator->generateUsername($event);
|
||||||
|
|
||||||
$exists = Event::query()
|
$normalized = strtolower($username);
|
||||||
->where('photobooth_username', $username)
|
|
||||||
->orWhere('sparkbooth_username', $username)
|
$exists = EventPhotoboothSetting::query()
|
||||||
->whereKeyNot($event->getKey())
|
->where('username', $normalized)
|
||||||
|
->where('event_id', '!=', $event->getKey())
|
||||||
->exists();
|
->exists();
|
||||||
|
|
||||||
if (! $exists) {
|
if (! $exists) {
|
||||||
return strtolower($username);
|
return $normalized;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Services\Photobooth;
|
namespace App\Services\Photobooth;
|
||||||
|
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
|
use App\Models\EventPhotoboothSetting;
|
||||||
use App\Models\Photo;
|
use App\Models\Photo;
|
||||||
use App\Services\Photobooth\Exceptions\SparkboothUploadException;
|
use App\Services\Photobooth\Exceptions\SparkboothUploadException;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
@@ -21,47 +22,52 @@ class SparkboothUploadService
|
|||||||
*/
|
*/
|
||||||
public function handleUpload(UploadedFile $media, ?string $username, ?string $password): array
|
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->enforceRateLimit($event);
|
||||||
$this->assertValidFile($media);
|
$this->assertValidFile($media);
|
||||||
|
|
||||||
$importDisk = config('photobooth.import.disk', 'photobooth');
|
$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');
|
$extension = strtolower($media->getClientOriginalExtension() ?: $media->extension() ?: 'jpg');
|
||||||
$filename = Str::uuid().'.'.$extension;
|
$filename = Str::uuid().'.'.$extension;
|
||||||
$relativePath = "{$basePath}/{$filename}";
|
$relativePath = "{$basePath}/{$filename}";
|
||||||
|
|
||||||
if (! $event->photobooth_path) {
|
if (! $setting->path) {
|
||||||
$event->forceFill([
|
$setting->forceFill([
|
||||||
'photobooth_path' => $basePath,
|
'path' => $basePath,
|
||||||
])->save();
|
])->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
Storage::disk($importDisk)->makeDirectory($basePath);
|
Storage::disk($importDisk)->makeDirectory($basePath);
|
||||||
Storage::disk($importDisk)->putFileAs($basePath, $media, $filename);
|
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) {
|
if (($summary['processed'] ?? 0) < 1) {
|
||||||
throw new SparkboothUploadException('ingest_failed', 'Upload failed, please retry.', 500);
|
throw new SparkboothUploadException('ingest_failed', 'Upload failed, please retry.', 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
$event->forceFill([
|
$setting->forceFill([
|
||||||
'sparkbooth_last_upload_at' => now(),
|
'last_upload_at' => now(),
|
||||||
'sparkbooth_uploads_last_24h' => ($event->sparkbooth_uploads_last_24h ?? 0) + 1,
|
'uploads_last_24h' => ($setting->uploads_last_24h ?? 0) + 1,
|
||||||
'sparkbooth_uploads_total' => ($event->sparkbooth_uploads_total ?? 0) + 1,
|
'uploads_total' => ($setting->uploads_total ?? 0) + 1,
|
||||||
])->save();
|
])->save();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'event' => $event->fresh(),
|
'event' => $event->fresh('photoboothSetting'),
|
||||||
'processed' => $summary['processed'] ?? 0,
|
'processed' => $summary['processed'] ?? 0,
|
||||||
'skipped' => $summary['skipped'] ?? 0,
|
'skipped' => $summary['skipped'] ?? 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function authenticate(?string $username, ?string $password): Event
|
protected function authenticate(?string $username, ?string $password): EventPhotoboothSetting
|
||||||
{
|
{
|
||||||
if (! $username || ! $password) {
|
if (! $username || ! $password) {
|
||||||
throw new SparkboothUploadException('missing_credentials', 'Invalid credentials', 401);
|
throw new SparkboothUploadException('missing_credentials', 'Invalid credentials', 401);
|
||||||
@@ -69,29 +75,34 @@ class SparkboothUploadService
|
|||||||
|
|
||||||
$normalizedUsername = strtolower(trim($username));
|
$normalizedUsername = strtolower(trim($username));
|
||||||
|
|
||||||
/** @var Event|null $event */
|
/** @var EventPhotoboothSetting|null $setting */
|
||||||
$event = Event::query()
|
$setting = EventPhotoboothSetting::query()
|
||||||
->whereRaw('LOWER(sparkbooth_username) = ?', [$normalizedUsername])
|
->where('username', $normalizedUsername)
|
||||||
|
->with('event')
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (! $event) {
|
if (! $setting) {
|
||||||
throw new SparkboothUploadException('invalid_credentials', 'Invalid credentials', 401);
|
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);
|
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);
|
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);
|
throw new SparkboothUploadException('expired', 'Upload access has expired', 403);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
47
database/factories/EventPhotoboothSettingFactory.php
Normal file
47
database/factories/EventPhotoboothSettingFactory.php
Normal 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',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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',
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -16,8 +16,8 @@ return new class extends Migration
|
|||||||
$table->json('settings')->nullable()->after('max_participants');
|
$table->json('settings')->nullable()->after('max_participants');
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->boolean('watermark_serve_originals')->default(false)->after('photobooth_metadata');
|
$table->boolean('watermark_serve_originals')->default(false)->after('settings');
|
||||||
$table->json('watermark_settings')->nullable()->after('photobooth_metadata');
|
$table->json('watermark_settings')->nullable()->after('watermark_serve_originals');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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',
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -22,7 +22,7 @@ class DatabaseSeeder extends Seeder
|
|||||||
EventTypesSeeder::class,
|
EventTypesSeeder::class,
|
||||||
EmotionsSeeder::class,
|
EmotionsSeeder::class,
|
||||||
TaskCollectionsSeeder::class,
|
TaskCollectionsSeeder::class,
|
||||||
InviteLayoutSeeder::class,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->call([
|
$this->call([
|
||||||
|
|||||||
17
database/seeders/EventPhotoboothSettingSeeder.php
Normal file
17
database/seeders/EventPhotoboothSettingSeeder.php
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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());
|
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]);
|
}, [typedPhotos, mode]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -134,7 +134,7 @@ export default function GalleryPreview({ token }: Props) {
|
|||||||
</div>
|
</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) => (
|
{items.map((p: PreviewPhoto) => (
|
||||||
<Link
|
<Link
|
||||||
key={p.id}
|
key={p.id}
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ export default function Header({ eventToken, title = '' }: { eventToken?: string
|
|||||||
const { event, status } = useEventData();
|
const { event, status } = useEventData();
|
||||||
const notificationCenter = useOptionalNotificationCenter();
|
const notificationCenter = useOptionalNotificationCenter();
|
||||||
const [notificationsOpen, setNotificationsOpen] = React.useState(false);
|
const [notificationsOpen, setNotificationsOpen] = React.useState(false);
|
||||||
const [statusFilter, setStatusFilter] = React.useState<'new' | 'read' | 'dismissed' | 'all'>('new');
|
|
||||||
const taskProgress = useGuestTaskProgress(eventToken);
|
const taskProgress = useGuestTaskProgress(eventToken);
|
||||||
const tasksEnabled = isTaskModeEnabled(event);
|
const tasksEnabled = isTaskModeEnabled(event);
|
||||||
const panelRef = React.useRef<HTMLDivElement | null>(null);
|
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)
|
? Math.min(1, taskProgress.completedCount / TASK_BADGE_TARGET)
|
||||||
: 0;
|
: 0;
|
||||||
const [activeTab, setActiveTab] = React.useState<'unread' | 'all' | 'status'>(center.unreadCount > 0 ? 'unread' : 'all');
|
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' | 'tips' | 'general'>('all');
|
||||||
const [scopeFilter, setScopeFilter] = React.useState<'all' | 'uploads' | 'tips' | 'general'>('all');
|
|
||||||
const pushState = usePushSubscription(eventToken);
|
const pushState = usePushSubscription(eventToken);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -306,19 +304,14 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
|
|||||||
default:
|
default:
|
||||||
base = center.notifications;
|
base = center.notifications;
|
||||||
}
|
}
|
||||||
|
return base;
|
||||||
if (statusFilter === 'all') return base;
|
}, [activeTab, center.notifications, unreadNotifications, uploadNotifications]);
|
||||||
return base.filter((item) => item.status === (statusFilter === 'new' ? 'new' : statusFilter));
|
|
||||||
}, [activeTab, center.notifications, unreadNotifications, uploadNotifications, statusFilter]);
|
|
||||||
|
|
||||||
const scopedNotifications = React.useMemo(() => {
|
const scopedNotifications = React.useMemo(() => {
|
||||||
if (scopeFilter === 'all') {
|
if (scopeFilter === 'all') {
|
||||||
return filteredNotifications;
|
return filteredNotifications;
|
||||||
}
|
}
|
||||||
return filteredNotifications.filter((item) => {
|
return filteredNotifications.filter((item) => {
|
||||||
if (scopeFilter === 'uploads') {
|
|
||||||
return item.type === 'upload_alert' || item.type === 'photo_activity';
|
|
||||||
}
|
|
||||||
if (scopeFilter === 'tips') {
|
if (scopeFilter === 'tips') {
|
||||||
return item.type === 'support_tip' || item.type === 'achievement_major';
|
return item.type === 'support_tip' || item.type === 'achievement_major';
|
||||||
}
|
}
|
||||||
@@ -332,7 +325,7 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={onToggle}
|
onClick={onToggle}
|
||||||
className="relative rounded-full bg-white/15 p-2 text-white transition hover:bg-white/30"
|
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 />
|
<Bell className="h-5 w-5" aria-hidden />
|
||||||
{badgeCount > 0 && (
|
{badgeCount > 0 && (
|
||||||
@@ -374,46 +367,33 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
|
|||||||
activeTab={activeTab}
|
activeTab={activeTab}
|
||||||
onTabChange={(next) => setActiveTab(next as typeof activeTab)}
|
onTabChange={(next) => setActiveTab(next as typeof activeTab)}
|
||||||
/>
|
/>
|
||||||
<div className="mt-2">
|
<div className="mt-3">
|
||||||
<label className="sr-only" htmlFor="notification-scope">
|
<div className="flex gap-2 overflow-x-auto text-xs whitespace-nowrap pb-1">
|
||||||
{t('header.notifications.scopeLabel', 'Bereich filtern')}
|
{(
|
||||||
</label>
|
[
|
||||||
<select
|
{ key: 'all', label: t('header.notifications.scope.all', 'Alle') },
|
||||||
id="notification-scope"
|
{ key: 'tips', label: t('header.notifications.scope.tips', 'Tipps & Achievements') },
|
||||||
value={scopeFilter}
|
{ key: 'general', label: t('header.notifications.scope.general', 'Allgemein') },
|
||||||
onChange={(event) => {
|
] as const
|
||||||
const next = event.target.value as typeof scopeFilter;
|
).map((option) => (
|
||||||
setScopeFilter(next);
|
<button
|
||||||
notificationCenter?.setFilters({ scope: next, status: statusFilter });
|
key={option.key}
|
||||||
}}
|
type="button"
|
||||||
className="w-full rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 shadow-sm"
|
onClick={() => {
|
||||||
>
|
setScopeFilter(option.key);
|
||||||
<option value="all">{t('header.notifications.scope.all', 'Alle')}</option>
|
center.setFilters({ scope: option.key });
|
||||||
<option value="uploads">{t('header.notifications.scope.uploads', 'Uploads/Status')}</option>
|
}}
|
||||||
<option value="tips">{t('header.notifications.scope.tips', 'Tipps & Achievements')}</option>
|
className={`rounded-full border px-3 py-1 font-semibold transition ${
|
||||||
<option value="general">{t('header.notifications.scope.general', 'Allgemein')}</option>
|
scopeFilter === option.key
|
||||||
</select>
|
? 'border-pink-200 bg-pink-50 text-pink-700'
|
||||||
<select
|
: 'border-slate-200 bg-white text-slate-600 hover:border-pink-200 hover:text-pink-700'
|
||||||
value={statusFilter}
|
}`}
|
||||||
onChange={(event) => {
|
>
|
||||||
const value = event.target.value as typeof statusFilter;
|
{option.label}
|
||||||
setStatusFilter(value);
|
</button>
|
||||||
notificationCenter?.setFilters({ status: value, scope: scopeFilter });
|
))}
|
||||||
}}
|
</div>
|
||||||
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>
|
|
||||||
</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">
|
<div className="mt-3 max-h-80 space-y-2 overflow-y-auto pr-1">
|
||||||
{center.loading ? (
|
{center.loading ? (
|
||||||
<NotificationSkeleton />
|
<NotificationSkeleton />
|
||||||
@@ -440,26 +420,27 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
|
|||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 rounded-2xl border border-slate-200 bg-slate-50/80 p-3">
|
{activeTab === 'status' && (
|
||||||
<div className="flex items-center justify-between text-sm">
|
<div className="mt-3 flex items-center justify-between rounded-xl bg-slate-50/90 px-3 py-2 text-xs text-slate-600">
|
||||||
<span className="text-slate-600">
|
<div className="flex items-center gap-2">
|
||||||
{t('header.notifications.queueLabel', 'Uploads in Warteschlange')}
|
<UploadCloud className="h-4 w-4 text-slate-400" aria-hidden />
|
||||||
</span>
|
<span>{t('header.notifications.queueLabel', 'Uploads in Warteschlange')}</span>
|
||||||
<span className="font-semibold text-slate-900">{center.queueCount}</span>
|
<span className="font-semibold text-slate-900">{center.queueCount}</span>
|
||||||
|
</div>
|
||||||
|
<Link
|
||||||
|
to={`/e/${encodeURIComponent(eventToken)}/queue`}
|
||||||
|
className="inline-flex items-center gap-1 font-semibold text-pink-600"
|
||||||
|
onClick={() => {
|
||||||
|
if (center.unreadCount > 0) {
|
||||||
|
void center.refresh();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('header.notifications.queueCta', 'Verlauf')}
|
||||||
|
<ArrowUpRight className="h-4 w-4" aria-hidden />
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<Link
|
)}
|
||||||
to={`/e/${encodeURIComponent(eventToken)}/queue`}
|
|
||||||
className="mt-2 inline-flex items-center gap-1 text-sm font-semibold text-pink-600"
|
|
||||||
onClick={() => {
|
|
||||||
if (center.unreadCount > 0) {
|
|
||||||
void center.refresh();
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t('header.notifications.queueCta', 'Upload-Verlauf öffnen')}
|
|
||||||
<ArrowUpRight className="h-4 w-4" aria-hidden />
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
{taskProgress && (
|
{taskProgress && (
|
||||||
<div className="mt-3 rounded-2xl border border-slate-200 bg-slate-50/90 p-3">
|
<div className="mt-3 rounded-2xl border border-slate-200 bg-slate-50/90 p-3">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
@@ -484,6 +465,12 @@ function NotificationButton({ center, eventToken, open, onToggle, panelRef, task
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<NotificationStatusBar
|
||||||
|
lastFetchedAt={center.lastFetchedAt}
|
||||||
|
isOffline={center.isOffline}
|
||||||
|
push={pushState}
|
||||||
|
t={t}
|
||||||
|
/>
|
||||||
</div>,
|
</div>,
|
||||||
typeof document !== 'undefined' ? document.body : undefined
|
typeof document !== 'undefined' ? document.body : undefined
|
||||||
)}
|
)}
|
||||||
@@ -719,7 +706,7 @@ function NotificationStatusBar({
|
|||||||
const pushButtonDisabled = push.loading || !push.supported || push.permission === 'denied';
|
const pushButtonDisabled = push.loading || !push.supported || push.permission === 'denied';
|
||||||
|
|
||||||
return (
|
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">
|
<div className="flex items-center justify-between">
|
||||||
<span>
|
<span>
|
||||||
{t('header.notifications.lastSync', 'Zuletzt aktualisiert')}: {label}
|
{t('header.notifications.lastSync', 'Zuletzt aktualisiert')}: {label}
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ export default function GalleryPage() {
|
|||||||
styleOverride={{ borderRadius: radius, fontFamily: headingFont }}
|
styleOverride={{ borderRadius: radius, fontFamily: headingFont }}
|
||||||
/>
|
/>
|
||||||
{loading && <p className="px-4" style={bodyFont ? { fontFamily: bodyFont } : undefined}>{t('galleryPage.loading', 'Lade…')}</p>}
|
{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) => {
|
{list.map((p: GalleryPhoto) => {
|
||||||
const imageUrl = normalizeImageUrl(p.thumbnail_path || p.file_path);
|
const imageUrl = normalizeImageUrl(p.thumbnail_path || p.file_path);
|
||||||
const createdLabel = p.created_at
|
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>
|
<span className="ml-3 truncate text-right">{p.uploader_name || t('galleryPage.photo.anonymous', 'Gast')}</span>
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div className="absolute right-3 top-3 z-10 flex items-center gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -279,13 +279,17 @@ export default function HomePage() {
|
|||||||
introArray.push(candidate);
|
introArray.push(candidate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const introMessage =
|
const introMessageRef = React.useRef<string | null>(null);
|
||||||
introArray.length > 0 ? introArray[Math.floor(Math.random() * introArray.length)] : '';
|
if (!introMessageRef.current) {
|
||||||
|
introMessageRef.current =
|
||||||
|
introArray.length > 0 ? introArray[Math.floor(Math.random() * introArray.length)] : '';
|
||||||
|
}
|
||||||
|
const introMessage = introMessageRef.current;
|
||||||
|
|
||||||
if (!tasksEnabled) {
|
if (!tasksEnabled) {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3 pb-24" style={bodyFont ? { fontFamily: bodyFont } : undefined}>
|
<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">
|
<p className="text-sm font-semibold text-foreground">
|
||||||
{t('home.welcomeLine').replace('{name}', displayName)}
|
{t('home.welcomeLine').replace('{name}', displayName)}
|
||||||
</p>
|
</p>
|
||||||
@@ -312,7 +316,7 @@ export default function HomePage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-0.5 pb-24" style={bodyFont ? { fontFamily: bodyFont } : undefined}>
|
<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">
|
<p className="text-sm font-semibold text-foreground">
|
||||||
{t('home.welcomeLine').replace('{name}', displayName)}
|
{t('home.welcomeLine').replace('{name}', displayName)}
|
||||||
</p>
|
</p>
|
||||||
@@ -476,12 +480,13 @@ function MissionActionCard({
|
|||||||
const bodyFont = branding.typography?.body ?? branding.fontFamily ?? undefined;
|
const bodyFont = branding.typography?.body ?? branding.fontFamily ?? undefined;
|
||||||
const cards = mission ? [mission, ...stack] : stack;
|
const cards = mission ? [mission, ...stack] : stack;
|
||||||
const shellRadius = `${radius + 10}px`;
|
const shellRadius = `${radius + 10}px`;
|
||||||
|
const normalizeText = (value: string | undefined | null) =>
|
||||||
|
(value ?? '').trim().toLowerCase().replace(/\s+/g, ' ');
|
||||||
|
|
||||||
const renderCardContent = (card: MissionPreview | null) => {
|
const renderCardContent = (card: MissionPreview | null) => {
|
||||||
const theme = getEmotionTheme(card?.emotion ?? null);
|
const theme = getEmotionTheme(card?.emotion ?? null);
|
||||||
const emotionIcon = getEmotionIcon(card?.emotion ?? null);
|
const emotionIcon = getEmotionIcon(card?.emotion ?? null);
|
||||||
const durationMinutes = card?.duration ?? 3;
|
const durationMinutes = card?.duration ?? 3;
|
||||||
const progressValue = Math.min(100, Math.max(20, (durationMinutes / 8) * 100));
|
|
||||||
const titleFont = headingFont ? { fontFamily: headingFont } : undefined;
|
const titleFont = headingFont ? { fontFamily: headingFont } : undefined;
|
||||||
const gradientBackground = card ? theme.gradientBackground : `linear-gradient(135deg, ${primary}, ${secondary})`;
|
const gradientBackground = card ? theme.gradientBackground : `linear-gradient(135deg, ${primary}, ${secondary})`;
|
||||||
|
|
||||||
@@ -524,7 +529,7 @@ function MissionActionCard({
|
|||||||
</Badge>
|
</Badge>
|
||||||
<div className="flex items-center gap-2 text-xs font-medium text-slate-600">
|
<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 />
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -538,7 +543,7 @@ function MissionActionCard({
|
|||||||
<div className="mt-4 text-center">
|
<div className="mt-4 text-center">
|
||||||
{card ? (
|
{card ? (
|
||||||
<p
|
<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)' }}
|
style={{ ...titleFont, textShadow: '0 6px 18px rgba(15,23,42,0.28)' }}
|
||||||
>
|
>
|
||||||
{card.title}
|
{card.title}
|
||||||
@@ -554,16 +559,18 @@ function MissionActionCard({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{card?.description && normalizeText(card.title) !== normalizeText(card.description) ? (
|
||||||
<div className="mt-4 space-y-2">
|
<div className="mt-4 space-y-2">
|
||||||
<Progress
|
<div className="flex items-center justify-between">
|
||||||
value={card ? progressValue : 35}
|
<div className="space-y-1 text-left">
|
||||||
className="h-2 overflow-hidden bg-white/70"
|
<p className="text-sm font-semibold text-slate-800" style={titleFont}>
|
||||||
/>
|
{card.title}
|
||||||
<div className="flex items-center justify-between text-[11px] font-semibold uppercase tracking-wide text-slate-500">
|
</p>
|
||||||
<span>Mission bereit</span>
|
<p className="text-sm leading-relaxed text-slate-600">{card.description}</p>
|
||||||
<span>{card ? 'Tippe zum Start' : 'Neue Mission lädt'}</span>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
) : null}
|
||||||
|
|
||||||
<div className="mt-4 grid grid-cols-[2fr_1fr] gap-2">
|
<div className="mt-4 grid grid-cols-[2fr_1fr] gap-2">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import { useParams, useLocation, useNavigate } from 'react-router-dom';
|
import { useParams, useLocation, useNavigate } from 'react-router-dom';
|
||||||
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
import { Dialog, DialogContent } from '@/components/ui/dialog';
|
||||||
import { Button } from '@/components/ui/button';
|
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 { likePhoto, createPhotoShareLink } from '../services/photosApi';
|
||||||
import { useTranslation } from '../i18n/useTranslation';
|
import { useTranslation } from '../i18n/useTranslation';
|
||||||
import { useToast } from '../components/ToastHost';
|
import { useToast } from '../components/ToastHost';
|
||||||
@@ -18,6 +20,7 @@ type Photo = {
|
|||||||
created_at?: string;
|
created_at?: string;
|
||||||
task_id?: number;
|
task_id?: number;
|
||||||
task_title?: string;
|
task_title?: string;
|
||||||
|
uploader_name?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Task = { id: number; title: string };
|
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 shareTitle = photo?.task_title ?? task?.title ?? t('share.title', 'Geteiltes Foto');
|
||||||
const shareText = t('share.shareText', { event: eventName ?? shareTitle ?? 'Fotospiel' });
|
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() {
|
async function openShareSheet() {
|
||||||
if (!photo || !eventToken) return;
|
if (!photo || !eventToken) return;
|
||||||
@@ -295,109 +316,151 @@ export default function PhotoLightbox({ photos, currentIndex, onClose, onIndexCh
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={true} onOpenChange={onOpenChange}>
|
<Dialog open={true} onOpenChange={onOpenChange}>
|
||||||
<DialogContent hideClose className="max-w-5xl border-0 bg-black p-0 text-white">
|
<DialogContent
|
||||||
{/* Header with controls */}
|
hideClose
|
||||||
<div className="flex items-center justify-between p-2">
|
className="max-w-6xl overflow-hidden rounded-3xl border border-white/10 bg-white/5 p-0 text-white shadow-2xl backdrop-blur-3xl"
|
||||||
<div className="flex items-center gap-2">
|
>
|
||||||
<Button
|
<div className="relative">
|
||||||
variant="secondary"
|
<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%)' }} />
|
||||||
size="sm"
|
|
||||||
onClick={onLike}
|
<div className="absolute top-4 left-0 right-0 z-30 flex items-center justify-between px-5">
|
||||||
disabled={liked}
|
<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">
|
||||||
<Heart className={`mr-1 h-4 w-4 ${liked ? 'fill-red-400 text-red-400' : ''}`} />
|
<X className="h-5 w-5" />
|
||||||
{likes}
|
</Button>
|
||||||
</Button>
|
<div className="rounded-full bg-white/10 px-3 py-1 text-xs font-semibold text-white/90">
|
||||||
<Button
|
{currentIndexVal + 1} / {currentPhotos.length}
|
||||||
variant="secondary"
|
</div>
|
||||||
size="sm"
|
</div>
|
||||||
onClick={openShareSheet}
|
<div className="flex items-center gap-2 rounded-full border border-white/20 bg-black/40 px-2 py-1 shadow-lg backdrop-blur">
|
||||||
disabled={!eventToken || !photo}
|
<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' : ''}`} />
|
||||||
<Share2 className="mr-1 h-4 w-4" />
|
</Button>
|
||||||
{t('share.button', 'Teilen')}
|
<Button
|
||||||
</Button>
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
onClick={openShareSheet}
|
||||||
|
disabled={!eventToken || !photo}
|
||||||
|
className="h-10 w-10 rounded-full text-white hover:bg-white/10"
|
||||||
|
>
|
||||||
|
<Share2 className="h-5 w-5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
{currentIndexVal > 0 && (
|
<div className="px-3 pb-5 pt-16">
|
||||||
<Button
|
<div
|
||||||
variant="ghost"
|
ref={touchRef}
|
||||||
size="sm"
|
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"
|
||||||
onClick={() => onIndexChange?.(currentIndexVal - 1)}
|
onTouchStart={handleTouchStart}
|
||||||
className="h-8 w-8 p-0"
|
onTouchMove={handleTouchMove}
|
||||||
>
|
onTouchEnd={handleTouchEnd}
|
||||||
<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" />
|
{currentIndexVal > 0 && (
|
||||||
</Button>
|
<Button
|
||||||
{currentIndexVal < currentPhotos.length - 1 && (
|
variant="ghost"
|
||||||
<Button
|
size="icon"
|
||||||
variant="ghost"
|
onClick={() => onIndexChange?.(currentIndexVal - 1)}
|
||||||
size="sm"
|
className="absolute left-3 top-1/2 -translate-y-1/2 rounded-full bg-white/90 text-slate-800 shadow-lg hover:bg-white"
|
||||||
onClick={() => onIndexChange?.(currentIndexVal + 1)}
|
>
|
||||||
className="h-8 w-8 p-0"
|
<ChevronLeft className="h-5 w-5" />
|
||||||
>
|
</Button>
|
||||||
<ChevronRight className="h-4 w-4" />
|
)}
|
||||||
</Button>
|
<img
|
||||||
|
src={photo?.file_path || photo?.thumbnail_path}
|
||||||
|
alt={t('lightbox.photoAlt')
|
||||||
|
.replace('{id}', `${photo?.id ?? ''}`)
|
||||||
|
.replace(
|
||||||
|
'{suffix}',
|
||||||
|
photo?.task_title
|
||||||
|
? t('lightbox.photoAltTaskSuffix').replace('{taskTitle}', photo.task_title)
|
||||||
|
: ''
|
||||||
|
)}
|
||||||
|
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>
|
||||||
|
|
||||||
|
<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>
|
||||||
</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
|
|
||||||
ref={touchRef}
|
|
||||||
className="flex items-center justify-center min-h-[60vh] p-4 relative overflow-hidden"
|
|
||||||
onTouchStart={handleTouchStart}
|
|
||||||
onTouchMove={handleTouchMove}
|
|
||||||
onTouchEnd={handleTouchEnd}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
src={photo?.file_path || photo?.thumbnail_path}
|
|
||||||
alt={t('lightbox.photoAlt')
|
|
||||||
.replace('{id}', `${photo?.id ?? ''}`)
|
|
||||||
.replace(
|
|
||||||
'{suffix}',
|
|
||||||
photo?.task_title
|
|
||||||
? t('lightbox.photoAltTaskSuffix').replace('{taskTitle}', photo.task_title)
|
|
||||||
: ''
|
|
||||||
)}
|
|
||||||
className="max-h-[80vh] max-w-full object-contain transition-transform duration-200"
|
|
||||||
onError={(e) => {
|
|
||||||
console.error('Image load error:', e);
|
|
||||||
(e.target as HTMLImageElement).style.display = 'none';
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</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>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<ShareSheet
|
<ShareSheet
|
||||||
open={shareSheet.loading || Boolean(shareSheet.url)}
|
open={shareSheet.loading || Boolean(shareSheet.url)}
|
||||||
photoId={photo?.id}
|
photoId={photo?.id}
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ export default function UploadPage() {
|
|||||||
const { t, locale } = useTranslation();
|
const { t, locale } = useTranslation();
|
||||||
const stats = useEventStats();
|
const stats = useEventStats();
|
||||||
const { branding } = useEventBranding();
|
const { branding } = useEventBranding();
|
||||||
const { event } = useEventData();
|
|
||||||
const radius = branding.buttons?.radius ?? 12;
|
const radius = branding.buttons?.radius ?? 12;
|
||||||
const buttonStyle = branding.buttons?.style ?? 'filled';
|
const buttonStyle = branding.buttons?.style ?? 'filled';
|
||||||
const linkColor = branding.buttons?.linkColor ?? branding.secondaryColor;
|
const linkColor = branding.buttons?.linkColor ?? branding.secondaryColor;
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import type { LocaleCode } from '../i18n/messages';
|
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>;
|
type RawPhoto = Record<string, unknown>;
|
||||||
|
|
||||||
export function usePollGalleryDelta(token: string, locale: LocaleCode) {
|
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) => ({
|
const newPhotos: Photo[] = rawPhotos.map((photo: RawPhoto) => ({
|
||||||
...(photo as Photo),
|
...(photo as Photo),
|
||||||
session_id: typeof photo.session_id === 'string' ? photo.session_id : (photo.guest_name as string | null) ?? null,
|
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) {
|
if (newPhotos.length > 0) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Tests\Feature\Console;
|
namespace Tests\Feature\Console;
|
||||||
|
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
|
use App\Models\EventPhotoboothSetting;
|
||||||
use App\Models\PhotoboothSetting;
|
use App\Models\PhotoboothSetting;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
@@ -23,15 +24,18 @@ class PhotoboothCleanupCommandTest extends TestCase
|
|||||||
'control_service_base_url' => 'https://control.test',
|
'control_service_base_url' => 'https://control.test',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$event = Event::factory()->create([
|
$event = Event::factory()->create();
|
||||||
'photobooth_enabled' => true,
|
$setting = EventPhotoboothSetting::factory()
|
||||||
'photobooth_username' => 'pbcleanup',
|
->for($event)
|
||||||
'photobooth_status' => 'active',
|
->create([
|
||||||
'photobooth_path' => '/photobooth/demo',
|
'enabled' => true,
|
||||||
'photobooth_expires_at' => now()->subDay(),
|
'mode' => 'ftp',
|
||||||
]);
|
'username' => 'pbcleanup',
|
||||||
$event->photobooth_password = 'CLEANUP';
|
'password' => 'CLEANUP',
|
||||||
$event->save();
|
'status' => 'active',
|
||||||
|
'path' => '/photobooth/demo',
|
||||||
|
'expires_at' => now()->subDay(),
|
||||||
|
]);
|
||||||
|
|
||||||
Http::fake([
|
Http::fake([
|
||||||
'https://control.test/*' => Http::response(['ok' => true], 200),
|
'https://control.test/*' => Http::response(['ok' => true], 200),
|
||||||
@@ -40,11 +44,11 @@ class PhotoboothCleanupCommandTest extends TestCase
|
|||||||
$this->artisan('photobooth:cleanup-expired')
|
$this->artisan('photobooth:cleanup-expired')
|
||||||
->assertExitCode(0);
|
->assertExitCode(0);
|
||||||
|
|
||||||
$event->refresh();
|
$setting->refresh();
|
||||||
|
|
||||||
$this->assertFalse($event->photobooth_enabled);
|
$this->assertFalse($setting->enabled);
|
||||||
$this->assertNull($event->photobooth_username);
|
$this->assertNull($setting->username);
|
||||||
$this->assertNotNull($event->photobooth_last_deprovisioned_at);
|
$this->assertNotNull($setting->last_deprovisioned_at);
|
||||||
|
|
||||||
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users/pbcleanup');
|
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users/pbcleanup');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Tests\Feature\Photobooth;
|
namespace Tests\Feature\Photobooth;
|
||||||
|
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
|
use App\Models\EventPhotoboothSetting;
|
||||||
use App\Models\PhotoboothSetting;
|
use App\Models\PhotoboothSetting;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
@@ -58,11 +59,13 @@ class PhotoboothControllerTest extends TenantTestCase
|
|||||||
->assertJsonPath('data.username', fn ($value) => is_string($value) && strlen($value) <= 10);
|
->assertJsonPath('data.username', fn ($value) => is_string($value) && strlen($value) <= 10);
|
||||||
|
|
||||||
$event->refresh();
|
$event->refresh();
|
||||||
$this->assertTrue($event->photobooth_enabled);
|
$setting = $event->photoboothSetting;
|
||||||
$this->assertNotNull($event->photobooth_username);
|
$this->assertNotNull($setting);
|
||||||
$this->assertNotNull($event->photobooth_password);
|
$this->assertTrue($setting->enabled);
|
||||||
$username = $event->photobooth_username;
|
$this->assertNotNull($setting->username);
|
||||||
$firstPassword = $event->photobooth_password;
|
$this->assertNotNull($setting->password);
|
||||||
|
$username = $setting->username;
|
||||||
|
$firstPassword = $setting->password;
|
||||||
|
|
||||||
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users' && $request['username'] === $username);
|
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);
|
->assertJsonPath('data.enabled', true);
|
||||||
|
|
||||||
$event->refresh();
|
$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");
|
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([
|
$event = Event::factory()->for($this->tenant)->create([
|
||||||
'slug' => 'photobooth-disable',
|
'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';
|
EventPhotoboothSetting::factory()
|
||||||
$event->save();
|
->for($event)
|
||||||
|
->create([
|
||||||
|
'enabled' => true,
|
||||||
|
'mode' => 'ftp',
|
||||||
|
'username' => 'pb123456',
|
||||||
|
'password' => 'SECRET12',
|
||||||
|
'path' => '/photobooth/demo',
|
||||||
|
'status' => 'active',
|
||||||
|
'expires_at' => now()->subDay(),
|
||||||
|
]);
|
||||||
|
|
||||||
Http::fake([
|
Http::fake([
|
||||||
'https://control.test/*' => Http::response(['ok' => true], 200),
|
'https://control.test/*' => Http::response(['ok' => true], 200),
|
||||||
@@ -102,8 +109,8 @@ class PhotoboothControllerTest extends TenantTestCase
|
|||||||
->assertJsonPath('data.username', null);
|
->assertJsonPath('data.username', null);
|
||||||
|
|
||||||
$event->refresh();
|
$event->refresh();
|
||||||
$this->assertFalse($event->photobooth_enabled);
|
$this->assertFalse($event->photoboothSetting?->enabled);
|
||||||
$this->assertNull($event->photobooth_username);
|
$this->assertNull($event->photoboothSetting?->username);
|
||||||
|
|
||||||
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users/pb123456');
|
Http::assertSent(fn ($request) => $request->url() === 'https://control.test/users/pb123456');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Tests\Feature\Photobooth;
|
namespace Tests\Feature\Photobooth;
|
||||||
|
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
|
use App\Models\EventPhotoboothSetting;
|
||||||
use App\Models\Photo;
|
use App\Models\Photo;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
use App\Services\EventJoinTokenService;
|
use App\Services\EventJoinTokenService;
|
||||||
@@ -22,18 +23,25 @@ class PhotoboothFilterTest extends TestCase
|
|||||||
->for($tenant)
|
->for($tenant)
|
||||||
->create([
|
->create([
|
||||||
'status' => 'published',
|
'status' => 'published',
|
||||||
'photobooth_enabled' => true,
|
]);
|
||||||
|
EventPhotoboothSetting::factory()
|
||||||
|
->for($event)
|
||||||
|
->create([
|
||||||
|
'enabled' => true,
|
||||||
|
'mode' => 'ftp',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Photo::factory()->create([
|
Photo::factory()->create([
|
||||||
'event_id' => $event->id,
|
'event_id' => $event->id,
|
||||||
'ingest_source' => Photo::SOURCE_PHOTOBOOTH,
|
'ingest_source' => Photo::SOURCE_PHOTOBOOTH,
|
||||||
'guest_name' => Photo::SOURCE_PHOTOBOOTH,
|
'guest_name' => Photo::SOURCE_PHOTOBOOTH,
|
||||||
|
'status' => 'approved',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Photo::factory()->create([
|
Photo::factory()->create([
|
||||||
'event_id' => $event->id,
|
'event_id' => $event->id,
|
||||||
'ingest_source' => Photo::SOURCE_GUEST_PWA,
|
'ingest_source' => Photo::SOURCE_GUEST_PWA,
|
||||||
|
'status' => 'approved',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/** @var EventJoinTokenService $tokens */
|
/** @var EventJoinTokenService $tokens */
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Jobs\ProcessPhotoSecurityScan;
|
|||||||
use App\Models\Emotion;
|
use App\Models\Emotion;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
use App\Models\EventPackage;
|
use App\Models\EventPackage;
|
||||||
|
use App\Models\EventPhotoboothSetting;
|
||||||
use App\Models\MediaStorageTarget;
|
use App\Models\MediaStorageTarget;
|
||||||
use App\Models\Package;
|
use App\Models\Package;
|
||||||
use App\Models\Photo;
|
use App\Models\Photo;
|
||||||
@@ -53,12 +54,15 @@ class PhotoboothIngestCommandTest extends TestCase
|
|||||||
->create([
|
->create([
|
||||||
'slug' => 'demo-event',
|
'slug' => 'demo-event',
|
||||||
'status' => 'published',
|
'status' => 'published',
|
||||||
'photobooth_enabled' => true,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$event->update([
|
$setting = EventPhotoboothSetting::factory()
|
||||||
'photobooth_path' => $tenant->slug.'/'.$event->id,
|
->for($event)
|
||||||
]);
|
->create([
|
||||||
|
'enabled' => true,
|
||||||
|
'mode' => 'ftp',
|
||||||
|
'path' => $tenant->slug.'/'.$event->id,
|
||||||
|
]);
|
||||||
|
|
||||||
$package = Package::factory()->create(['max_photos' => 5]);
|
$package = Package::factory()->create(['max_photos' => 5]);
|
||||||
EventPackage::create([
|
EventPackage::create([
|
||||||
@@ -68,7 +72,8 @@ class PhotoboothIngestCommandTest extends TestCase
|
|||||||
'used_photos' => 0,
|
'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();
|
Emotion::factory()->create();
|
||||||
|
|
||||||
Bus::fake();
|
Bus::fake();
|
||||||
@@ -81,7 +86,7 @@ class PhotoboothIngestCommandTest extends TestCase
|
|||||||
'ingest_source' => Photo::SOURCE_PHOTOBOOTH,
|
'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);
|
Bus::assertDispatched(ProcessPhotoSecurityScan::class);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user