added upload queue notifications

This commit is contained in:
Codex Agent
2025-12-21 12:37:20 +01:00
parent 1e6027f438
commit 6ee40745ca
13 changed files with 566 additions and 114 deletions

View File

@@ -1233,6 +1233,24 @@ class EventPublicController extends BaseController
return $this->makeSignedGalleryAssetUrlForId($token, (int) $photo->id, $variant);
}
private function makeSignedPendingAssetUrl(string $token, int $photoId, string $variant, string $deviceId): ?string
{
if (! in_array($variant, ['thumbnail', 'full'], true)) {
return null;
}
return URL::temporarySignedRoute(
'api.v1.events.pending-photos.asset',
now()->addSeconds(self::SIGNED_URL_TTL_SECONDS),
[
'token' => $token,
'photo' => $photoId,
'variant' => $variant,
'device_id' => $deviceId,
]
);
}
private function makeSignedBrandingUrl(?string $path): ?string
{
if (! $path) {
@@ -1488,6 +1506,53 @@ class EventPublicController extends BaseController
]);
}
public function pendingUploads(Request $request, string $token)
{
$result = $this->resolvePublishedEvent($request, $token, ['id']);
if ($result instanceof JsonResponse) {
return $result;
}
[$event] = $result;
$deviceId = $this->resolveDeviceIdentifier($request);
if ($deviceId === 'anonymous') {
return response()->json([
'data' => [],
'meta' => ['total_count' => 0],
])->header('Cache-Control', 'no-store');
}
$limit = (int) $request->query('limit', 12);
$limit = max(1, min($limit, 30));
$baseQuery = Photo::query()
->where('event_id', $event->id)
->where('status', 'pending')
->where('created_by_device_id', $deviceId);
$totalCount = (clone $baseQuery)->count();
$photos = $baseQuery
->orderByDesc('created_at')
->limit($limit)
->get(['id', 'created_at', 'status']);
$data = $photos->map(fn (Photo $photo) => [
'id' => $photo->id,
'status' => $photo->status,
'created_at' => $photo->created_at?->toIso8601String(),
'thumbnail_url' => $this->makeSignedPendingAssetUrl($token, (int) $photo->id, 'thumbnail', $deviceId),
'full_url' => $this->makeSignedPendingAssetUrl($token, (int) $photo->id, 'full', $deviceId),
])->all();
return response()->json([
'data' => $data,
'meta' => ['total_count' => $totalCount],
])->header('Cache-Control', 'no-store');
}
public function createShareLink(Request $request, string $token, Photo $photo)
{
$resolved = $this->resolvePublishedEvent($request, $token, ['id']);
@@ -1699,6 +1764,53 @@ class EventPublicController extends BaseController
return $this->streamGalleryPhoto($event, $record, $variantPreference, 'inline');
}
public function pendingPhotoAsset(Request $request, string $token, int $photo, string $variant)
{
$resolved = $this->resolveGalleryEvent($request, $token);
if ($resolved instanceof JsonResponse) {
return $resolved;
}
[$event] = $resolved;
$deviceId = $this->normalizeGuestIdentifier((string) $request->query('device_id', ''));
if ($deviceId === '') {
return ApiError::response(
'pending_photo_forbidden',
'Pending Photo Access Denied',
'The pending photo cannot be accessed.',
Response::HTTP_FORBIDDEN
);
}
$record = Photo::with('mediaAsset')
->where('id', $photo)
->where('event_id', $event->id)
->where('status', 'pending')
->where('created_by_device_id', $deviceId)
->first();
if (! $record) {
return ApiError::response(
'photo_not_found',
'Photo Not Found',
'The requested photo is no longer available.',
Response::HTTP_NOT_FOUND,
[
'photo_id' => $photo,
'event_id' => $event->id,
]
);
}
$variantPreference = $variant === 'thumbnail'
? ['thumbnail', 'original']
: ['original'];
return $this->streamGalleryPhoto($event, $record, $variantPreference, 'inline');
}
public function galleryPhotoDownload(Request $request, string $token, int $photo)
{
$resolved = $this->resolveGalleryEvent($request, $token);
@@ -2897,6 +3009,7 @@ class EventPublicController extends BaseController
'tenant_id' => $tenantModel->id,
'task_id' => $validated['task_id'] ?? null,
'guest_name' => $validated['guest_name'] ?? $deviceId,
'created_by_device_id' => $deviceId !== 'anonymous' ? $deviceId : null,
'file_path' => $url,
'thumbnail_path' => $thumbUrl,
'likes_count' => 0,