mapCalendarToUser->getUserId($user); if (null === $id) { return null; } try { $automaticRepliesSettings = $this->machineHttpClient ->request('GET', 'users/' . $id . '/mailboxSettings/automaticRepliesSetting') ->toArray(true); } catch (ClientExceptionInterface|DecodingExceptionInterface|RedirectionExceptionInterface|TransportExceptionInterface $e) { throw new UserAbsenceSyncException("Error receiving response for mailboxSettings", 0, $e); } catch (ServerExceptionInterface $e) { throw new UserAbsenceSyncException("Server error receiving response for mailboxSettings", 0, $e); } if (!array_key_exists("status", $automaticRepliesSettings)) { throw new \LogicException("no key \"status\" on automatic replies settings: " . json_encode($automaticRepliesSettings, JSON_THROW_ON_ERROR)); } return match ($automaticRepliesSettings['status']) { 'disabled' => false, 'alwaysEnabled' => true, 'scheduled' => RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledStartDateTime']['dateTime']) < $this->clock->now() && RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledEndDateTime']['dateTime']) > $this->clock->now(), default => throw new UserAbsenceSyncException("this status is not documented by Microsoft") }; } }