mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 18:13:48 +00:00
Sync user absence / presence within MapAndSubscribeUserCalendarCommand
This commit is contained in:
@@ -65,7 +65,7 @@ class MSGraphUserRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|User[]
|
||||
* @return array<User>
|
||||
*/
|
||||
public function findByMostOldSubscriptionOrWithoutSubscriptionOrData(DateInterval $interval, int $limit = 50, int $offset = 0): array
|
||||
{
|
||||
|
@@ -13,6 +13,7 @@ namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use Chill\CalendarBundle\Exception\UserAbsenceSyncException;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
@@ -43,7 +44,7 @@ final readonly class MSUserAbsenceReader implements MSUserAbsenceReaderInterface
|
||||
|
||||
try {
|
||||
$automaticRepliesSettings = $this->machineHttpClient
|
||||
->request('GET', '/users/' . $id . '/mailboxSettings/automaticRepliesSetting')
|
||||
->request('GET', 'users/' . $id . '/mailboxSettings/automaticRepliesSetting')
|
||||
->toArray(true);
|
||||
} catch (ClientExceptionInterface|DecodingExceptionInterface|RedirectionExceptionInterface|TransportExceptionInterface $e) {
|
||||
throw new UserAbsenceSyncException("Error receiving response for mailboxSettings", 0, $e);
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user