From 7a9e133a92f8b2f342e15e05d6982796f34f90c0 Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Mon, 4 May 2026 16:59:57 +0200 Subject: [PATCH] Updated rempte Pc sync --- src/Dto/Output/ClientOutput.php | 9 ++++ .../UdsSyncOnClientStatusListener.php | 44 ++----------------- 2 files changed, 13 insertions(+), 40 deletions(-) diff --git a/src/Dto/Output/ClientOutput.php b/src/Dto/Output/ClientOutput.php index 6f81c9c..0560e04 100644 --- a/src/Dto/Output/ClientOutput.php +++ b/src/Dto/Output/ClientOutput.php @@ -182,6 +182,13 @@ final class ClientOutput extends AbstractOutput )] public ?BootServerOutput $bootServer = null; + #[Groups(['client:read', 'organizational-unit:read'])] + #[ApiProperty( + description: 'Indica si el cliente tiene una reserva activa de RemotePC (UDS)', + example: false + )] + public bool $isRemotePcActive = false; + public function __construct(Client $client) { parent::__construct($client); @@ -236,6 +243,8 @@ final class ClientOutput extends AbstractOutput if ($client->getBootServer()) { $this->bootServer = new BootServerOutput($client->getBootServer()); } + + $this->isRemotePcActive = (bool) $client->getRemotePC()?->isReservedActive(); } public function convertMaskToCIDR($mask): int diff --git a/src/EventListener/UdsSyncOnClientStatusListener.php b/src/EventListener/UdsSyncOnClientStatusListener.php index 30f1e6d..aa3794d 100644 --- a/src/EventListener/UdsSyncOnClientStatusListener.php +++ b/src/EventListener/UdsSyncOnClientStatusListener.php @@ -25,49 +25,13 @@ class UdsSyncOnClientStatusListener public function preUpdate(PreUpdateEventArgs $args): void { - $entity = $args->getObject(); - - if (!$entity instanceof Client) { - return; - } - - $changeSet = $args->getObjectManager()->getUnitOfWork()->getEntityChangeSet($entity); - - if (!array_key_exists('status', $changeSet)) { - return; - } - - // Don't sync while the machine has an active RemotePC reservation. - // Any status change during a reservation (INITIALIZING, OG_LIVE via InclusionCliente, - // WINDOWS after boot, etc.) would compute max_srvs=0/visible=false and cause UDS - // to cancel the active session with an unreserve call. - // The sync will fire again after unreserve clears the reservation (reservedUntil=null). - $remotePC = $entity->getRemotePC(); - if ($remotePC && $remotePC->isReservedActive()) { - return; - } - - $ou = $entity->getOrganizationalUnit(); - if (!$ou || !$ou->getRemoteCalendar()) { - return; - } - - $this->syncNeeded = true; + // UDS sync on client status change is disabled. + // Sync is now triggered manually via the calendar sync button. } public function postFlush(PostFlushEventArgs $args): void { - if (!$this->syncNeeded) { - return; - } - - $this->syncNeeded = false; - - try { - $this->udsClient->__invoke(); - $this->logger->info('UDS sync triggered by client status change'); - } catch (\Throwable $e) { - $this->logger->warning('UDS sync failed after client status change', ['error' => $e->getMessage()]); - } + // UDS sync on client status change is disabled. + // Sync is now triggered manually via the calendar sync button. } }