Files
desktop/public/api/system/deploy-status/index.php
Lars Gebhardt-Kusche bd5cb9364c
All checks were successful
Deploy / deploy-staging (push) Successful in 27s
Deploy / deploy-production (push) Has been skipped
asdasd
2026-06-25 01:00:06 +02:00

40 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
require_once dirname(__DIR__, 4) . '/src/App/bootstrap.php';
use App\ConfigLoader;
use App\GiteaDeployStatusService;
session_start();
$authUser = is_array($_SESSION['desktop_auth']['user'] ?? null) ? $_SESSION['desktop_auth']['user'] : [];
$groups = array_values(array_map('strval', (array) ($authUser['groups'] ?? [])));
$isAdmin = in_array('administrators', $groups, true);
$projectRoot = dirname(__DIR__, 4);
$service = new GiteaDeployStatusService(ConfigLoader::load($projectRoot, 'gitea'));
if (!$service->shouldShowInTray($isAdmin)) {
respond([
'error' => 'forbidden',
'message' => 'Kein Zugriff auf den Gitea-Deploy-Status.',
], 403);
}
respond([
'data' => $service->status(),
]);
/**
* @param array<string, mixed> $payload
*/
function respond(array $payload, int $statusCode = 200): never
{
http_response_code($statusCode);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($payload, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}