mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fixed: [calendar ms synchro] do not throw an error if we are not allowed
to get the default calendar
This commit is contained in:
parent
efa475df0f
commit
4eb7d10e45
@ -22,6 +22,7 @@ use Chill\MainBundle\Entity\User;
|
|||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
|
|
||||||
@ -74,9 +75,18 @@ class MapCalendarToUser
|
|||||||
|
|
||||||
public function getDefaultUserCalendar(string $idOrUserPrincipalName): ?array
|
public function getDefaultUserCalendar(string $idOrUserPrincipalName): ?array
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$value = $this->machineHttpClient->request('GET', "users/{$idOrUserPrincipalName}/calendars", [
|
$value = $this->machineHttpClient->request('GET', "users/{$idOrUserPrincipalName}/calendars", [
|
||||||
'query' => ['$filter' => 'isDefaultCalendar eq true'],
|
'query' => ['$filter' => 'isDefaultCalendar eq true'],
|
||||||
])->toArray()['value'];
|
])->toArray()['value'];
|
||||||
|
} catch (ClientExceptionInterface $e) {
|
||||||
|
$this->logger->error('[MapCalendarToUser] Error while listing calendars for a user', [
|
||||||
|
'http_status_code' => $e->getResponse()->getStatusCode(),
|
||||||
|
'id_user' => $idOrUserPrincipalName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return $value[0] ?? null;
|
return $value[0] ?? null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user