Merge pull request 'change-status-poweroff' (#79) from change-status-poweroff into main
ogcore-debian-package/pipeline/head This commit looks good Details
testing/ogcore-api/pipeline/head This commit looks good Details

Reviewed-on: #79
pull/82/head 1.2.10
Juan Manuel Bardallo 2026-03-26 14:14:58 +01:00
commit 9f5eaefb9e
2 changed files with 26 additions and 0 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## [1.2.10] - 2026-03-25
### Added
Modificado StatusController para que al recibir un webhook de Poweroff o reboot actualice el estado de las trazas en progreso y las ponga como finalizadas.
## [1.2.9] - 2026-03-25
### Added
- Nuevo webhook `START_SCRIPT` en StatusController que permite crear automáticamente una entidad Trace y poner el equipo local en estado `BUSY` cuando un cliente inicia sus propios scripts de forma autónoma (ej: menús locales de ogLive).

View File

@ -96,6 +96,28 @@ class StatusController extends AbstractController
}
}
}
if (isset($data['nfn']) && in_array($data['nfn'], ['REBOOT', 'POWEROFF'], true)) {
$clientIp = $data['iph'] ?? $request->getClientIp();
$client = $this->entityManager->getRepository(Client::class)->findOneBy(['ip' => $clientIp]);
if ($client) {
$traces = $this->entityManager->getRepository(Trace::class)->findBy(['client' => $client, 'status' => TraceStatus::IN_PROGRESS]);
foreach ($traces as $trace) {
$trace->setStatus(TraceStatus::SUCCESS);
$trace->setFinishedAt(new \DateTime());
$this->entityManager->persist($trace);
}
if ($client->getStatus() === ClientStatus::BUSY) {
$newStatus = ($data['nfn'] === 'REBOOT') ? ClientStatus::INITIALIZING : ClientStatus::TURNING_OFF;
$client->setStatus($newStatus);
$this->entityManager->persist($client);
}
$this->entityManager->flush();
$this->logger->info('Reboot/Poweroff webhook received. Automatically resolved in-progress traces.', ['num_traces' => count($traces), 'nfn' => $data['nfn']]);
}
}
if (isset($data['progress'])){
$trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]);