Revisions now call publishing only what publishes: a project's status is whether the work is active, and a service is published by its flag. The fake identity server answers by token, so a test can sign in a second person. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use App\Http\Controllers\Api\V1\Concerns\ResolvesContent;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Support\AdminContent;
|
|
use App\Support\PreviewLink;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* Links to see a draft on the real site, one per language it has an address
|
|
* in — the panel's preview button. Each opens that one record only, and stops
|
|
* working after `PreviewLink::HOURS`.
|
|
*/
|
|
class PreviewController extends Controller
|
|
{
|
|
use ResolvesContent;
|
|
|
|
public function store(Request $request): JsonResponse
|
|
{
|
|
$record = $this->record($request);
|
|
|
|
$this->authorize('view', $record);
|
|
|
|
$type = AdminContent::PREVIEWABLE[$this->content($request)];
|
|
|
|
$links = collect(array_keys((array) config('locales.supported')))
|
|
->mapWithKeys(fn (string $locale) => [$locale => PreviewLink::for($record, $type, $locale)])
|
|
->filter()
|
|
->all();
|
|
|
|
return response()->json([
|
|
'data' => [
|
|
'links' => (object) $links,
|
|
'expires_at' => now()->addHours(PreviewLink::HOURS)->toIso8601String(),
|
|
],
|
|
], 201);
|
|
}
|
|
}
|