обновление лаунчера + упущенная картинка на лендинг
This commit is contained in:
@@ -4,10 +4,10 @@ namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
|
||||
class LauncherController extends Controller
|
||||
{
|
||||
#[OA\Get(
|
||||
@@ -120,7 +120,7 @@ class LauncherController extends Controller
|
||||
public function download(string $path): JsonResponse
|
||||
{
|
||||
$disk = Storage::disk($this->disk());
|
||||
$fullPath = $this->basePath().'/'.$path;
|
||||
$fullPath = $this->basePath() . '/' . $path;
|
||||
|
||||
if (! $disk->exists($fullPath)) {
|
||||
return response()->json(['message' => 'Файл не найден.'], 404);
|
||||
@@ -135,6 +135,75 @@ class LauncherController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
#[OA\Post(
|
||||
path: '/api/service/update-appcast',
|
||||
summary: 'Обновить appcast лаунчера',
|
||||
description: 'Служебный endpoint для разработчика лаунчера. Принимает готовый XML appcast в формате RSS 2.0/Sparkle, который использует Flutter-пакет `upgrader`, и сохраняет его как публичный `/appcast.xml` на сервере. Тело запроса передается как raw XML, без JSON-обертки.',
|
||||
tags: ['Launcher Service'],
|
||||
security: [['launcherAuth' => []]],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\MediaType(
|
||||
mediaType: 'application/xml',
|
||||
schema: new OA\Schema(
|
||||
type: 'string',
|
||||
example: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<rss version=\"2.0\" xmlns:sparkle=\"http://www.andymatuschak.org/xml-namespaces/sparkle\">\n <channel>\n <title>Moonwell Launcher - Appcast</title>\n <item>\n <title>Version 1.2.0</title>\n <description>Описание изменений для окна обновления.</description>\n <pubDate>Sat, 16 May 2026 12:00:00 +0400</pubDate>\n <enclosure url=\"https://moonwell.su/launcher/download\" sparkle:version=\"1.2.0\" sparkle:os=\"windows\" />\n </item>\n </channel>\n</rss>",
|
||||
),
|
||||
),
|
||||
),
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'Appcast сохранен',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'message', type: 'string', example: 'XML saved'),
|
||||
],
|
||||
),
|
||||
),
|
||||
new OA\Response(
|
||||
response: 403,
|
||||
description: 'Нет доступа или передано пустое тело запроса',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'message', type: 'string', example: 'empty body'),
|
||||
],
|
||||
),
|
||||
),
|
||||
new OA\Response(
|
||||
response: 500,
|
||||
description: 'Не удалось сохранить appcast.xml',
|
||||
content: new OA\JsonContent(
|
||||
properties: [
|
||||
new OA\Property(property: 'message', type: 'string', example: 'Failed to save XML'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)]
|
||||
public function updateAppcast(Request $request): JsonResponse
|
||||
{
|
||||
$xml = $request->getContent();
|
||||
|
||||
if (blank($xml)) {
|
||||
return response()->json([
|
||||
'message' => 'empty body',
|
||||
], 403);
|
||||
}
|
||||
|
||||
$saved = Storage::disk('public')->put('appcast.xml', $xml);
|
||||
|
||||
if (! $saved) {
|
||||
return response()->json([
|
||||
'message' => 'Failed to save XML',
|
||||
], 500);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'XML saved',
|
||||
]);
|
||||
}
|
||||
|
||||
private function disk(): string
|
||||
{
|
||||
return config('moonwell.launcher.disk', 's3');
|
||||
|
||||
Reference in New Issue
Block a user