presseportale/routes/legacy-api.php
Kevin Adametz a3fd361ece Legacy-API-Paritaet S1+S2: connektar-Flow verhaltensgleich + KI-Schalter
Eigene Compat-Controller (Api/Legacy) fuer die 5 real genutzten
/service-Endpoints (Prod-Log-Beleg): Company-/Kontakt-Create (liefen
410!), PM-Create, Bild-Upload, published-only-GET — verschachtelte
Alt-Params, 201+Location+{}, Alt-Fehlerformat, Hit-Zaehlung,
Legacy-Land-Mapping.

- Anlegen = Einreichen (Alt-Verhalten); Sofort-Publish via neuer
  Permission api:immediate-publication (WS-7: connektar zuweisen)
- Admin-Schalter 'KI-Pruefung Legacy-API' (app_settings-Tabelle,
  Toggle auf /admin/press-releases): an = review + KI-Routing
- Admin-PM-Liste: KI-Spalte (Ampel-Badge) + manueller Pruef-Button
  ohne Routing fuer ungepruefte PMs
- Mails bei API-Einlieferern an Pressekontakt, sonst Firmen-Mail,
  Fallback Einlieferer (User-Entscheidung 10.07.)
- Tests: LegacyServiceParityTest (connektar-Flow end-to-end);
  Suite 1182 gruen

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-10 14:09:40 +00:00

60 lines
3.5 KiB
PHP

<?php
use App\Http\Controllers\Api\Legacy\LegacyCompanyController;
use App\Http\Controllers\Api\Legacy\LegacyContactController;
use App\Http\Controllers\Api\Legacy\LegacyPressReleaseController;
use App\Http\Controllers\Api\Legacy\LegacyPressReleaseImageController;
use App\Http\Controllers\Api\V1\CompanyController;
use App\Http\Controllers\Api\V1\PressReleaseController;
use App\Http\Controllers\Api\V1\PressReleaseImageController;
use App\Http\Middleware\EnsureApiTokenRateLimit;
use App\Http\Middleware\EnsureApiUserIsActive;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Legacy-API-Aliasse (Übernahme bestehender Integrationen, 06.07.2026)
|--------------------------------------------------------------------------
|
| Die Altportale dokumentierten ihre API unter /service/... (JSON,
| X-ApiKey-Header). Diese Aliasse bilden die dokumentierte Alt-Oberfläche
| auf die v1-Controller ab, damit bestehende Kundenintegrationen nach dem
| Relaunch weiterlaufen (Auth: importierte Legacy-Keys, s. Middleware
| RejectLegacyApiKeys + legacy:import-api-keys). Läuft in der
| api-Middleware-Gruppe (bootstrap/app.php, then:) — ohne /api-Präfix.
|
| Nicht abgebildet (waren dokumentiert, existieren in v1 nicht):
| Pressemappen/Kontakte ANLEGEN sowie Einzelbild-GET — dafür antwortet
| der Fallback mit einem Hinweis auf Kundenkonto und neue Doku.
|
*/
Route::prefix('service')
->name('legacy-service.')
->middleware(['auth:sanctum', EnsureApiUserIsActive::class, EnsureApiTokenRateLimit::class])
->group(function (): void {
// Paritäts-Controller (10.07.2026, dev/release/api-legacy-paritaet.md):
// die 5 real genutzten Alt-Calls (connektar-Flow) verhaltensgleich —
// verschachtelte Alt-Params, Alt-Responses, Anlegen = Einreichen.
Route::post('pressreleases', [LegacyPressReleaseController::class, 'store'])->name('pressreleases.store');
Route::get('pressreleases/{pressRelease}', [LegacyPressReleaseController::class, 'show'])->name('pressreleases.show');
Route::post('pressreleases/{pressRelease}/images', [LegacyPressReleaseImageController::class, 'store'])->name('pressreleases.images.store');
Route::post('users/me/companies', [LegacyCompanyController::class, 'store'])->name('companies.store');
Route::post('users/me/companies/{company}/contacts', [LegacyContactController::class, 'store'])->name('contacts.store');
// Real ungenutzte, aber harmlose Lese-Aliasse (v1-Format).
Route::get('pressreleases', [PressReleaseController::class, 'index'])->name('pressreleases.index');
Route::get('pressreleases/{pressRelease}/images', [PressReleaseImageController::class, 'index'])->name('pressreleases.images.index');
Route::get('users/me/companies', [CompanyController::class, 'index'])->name('companies.index');
Route::get('users/me/companies/{company}', [CompanyController::class, 'show'])->name('companies.show');
});
// Alles Übrige unter /service/… (inkl. der nicht übernommenen
// Schreib-Endpoints für Pressemappen/Kontakte): klarer Hinweis statt 404.
Route::any('service/{path?}', function () {
return response()->json([
'message' => 'This legacy endpoint is not available anymore. Companies and press contacts are managed in your customer account; see the current API reference for everything else.',
'account_url' => url('/customer'),
'docs_url' => url('/docs/api/v1'),
], 410);
})->where('path', '.*')->name('legacy-service.gone');