Sync user absence / presence within MapAndSubscribeUserCalendarCommand

This commit is contained in:
2023-07-06 21:33:01 +02:00
parent 2861945a52
commit 77d4b13c1b
5 changed files with 109 additions and 87 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
use Chill\MainBundle\Entity\User;
use Psr\Log\LoggerInterface;
use Symfony\Component\Clock\ClockInterface;
readonly class MSUserAbsenceSync
@@ -19,6 +20,7 @@ readonly class MSUserAbsenceSync
public function __construct(
private MSUserAbsenceReaderInterface $absenceReader,
private ClockInterface $clock,
private LoggerInterface $logger,
) {
}
@@ -35,9 +37,13 @@ readonly class MSUserAbsenceSync
return;
}
$this->logger->info("will change user absence", ['userId' => $user->getId()]);
if ($absence) {
$this->logger->debug("make user absent", ['userId' => $user->getId()]);
$user->setAbsenceStart($this->clock->now());
} else {
$this->logger->debug("make user present", ['userId' => $user->getId()]);
$user->setAbsenceStart(null);
}
}