json(['ok' => true, 'result' => $check->run()]); } catch (ServerError $e) { return $this->serverError($e); } } public function install(Request $request, Updater $updater, UpdateProgress $progress): JsonResponse { if ($progress->isRunning()) { return response()->json(['ok' => false, 'message' => 'Es läuft bereits eine Aktualisierung.'], 409); } // Der Ablauf läuft serverseitig zu Ende, auch wenn der Browser die Verbindung trennt. @set_time_limit(0); @ignore_user_abort(true); try { $result = $updater->installUpdate($request->user()?->id); return response()->json(['ok' => true, 'result' => $result]); } catch (ServerError $e) { return $this->serverError($e); } catch (Throwable $e) { return response()->json(['ok' => false, 'message' => $e->getMessage()], 500); } } public function progress(UpdateProgress $progress): JsonResponse { return response()->json($progress->get()); } public function channel(Request $request, Channels $channels): JsonResponse { $validated = $request->validate([ 'channel' => ['required', 'string', Rule::in(array_keys($channels->all()))], ]); $channels->setActive($validated['channel']); Audit::log('update.channel_changed', ['channel' => $validated['channel']]); return response()->json(['ok' => true, 'channel' => $validated['channel']]); } public function migrations(Migrations $migrations): JsonResponse { @set_time_limit(0); try { $count = $migrations->run(); @file_put_contents(storage_path('.migrations-fingerprint'), $migrations->fingerprint()); Audit::log('update.migrations', ['migrations' => $count]); return response()->json(['ok' => true, 'count' => $count, 'status' => $migrations->status()]); } catch (Throwable $e) { Audit::log('update.migrations_failed', ['error' => $e->getMessage()]); return response()->json(['ok' => false, 'message' => 'Migrationen fehlgeschlagen: '.$e->getMessage()], 500); } } private function serverError(ServerError $e): JsonResponse { return response()->json([ 'ok' => false, 'code' => $e->errorCode, 'message' => ServerMessages::for($e), 'license_input' => $e->needsLicenseInput(), ], 200); } }