make the script which subscribe to user calendars on ms-graph more tolerant to errors

The script does not fails and exit when some calendar settings are not reachable
This commit is contained in:
Julien Fastré 2024-04-26 13:47:25 +02:00
parent 59005e83c4
commit 3e2ff463bc
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 6 additions and 3 deletions

View File

@ -0,0 +1,6 @@
kind: Feature
body: Make the script which subscribe to microsoft calendars changes more tolerant
to errors or missing configuration on the microsoft side
time: 2024-04-26T13:48:31.476415017+02:00
custom:
Issue: "197"

View File

@ -49,8 +49,6 @@ final class MapAndSubscribeUserCalendarCommand extends Command
$limit = 50; $limit = 50;
$offset = 0; $offset = 0;
/** @var \DateInterval $interval the interval before the end of the expiration */
$interval = new \DateInterval('P1D');
$expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($input->getOption('subscription-duration'))); $expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($input->getOption('subscription-duration')));
$users = $this->userRepository->findAllAsArray('fr'); $users = $this->userRepository->findAllAsArray('fr');
$created = 0; $created = 0;
@ -93,7 +91,6 @@ final class MapAndSubscribeUserCalendarCommand extends Command
} catch (UserAbsenceSyncException $e) { } catch (UserAbsenceSyncException $e) {
$this->logger->error('could not sync user absence', ['userId' => $user->getId(), 'email' => $user->getEmail(), 'exception' => $e->getTraceAsString(), 'message' => $e->getMessage()]); $this->logger->error('could not sync user absence', ['userId' => $user->getId(), 'email' => $user->getEmail(), 'exception' => $e->getTraceAsString(), 'message' => $e->getMessage()]);
$output->writeln(sprintf('Could not sync user absence: id: %s and email: %s', $user->getId(), $user->getEmail())); $output->writeln(sprintf('Could not sync user absence: id: %s and email: %s', $user->getId(), $user->getEmail()));
throw $e;
} }
// we first try to renew an existing subscription, if any. // we first try to renew an existing subscription, if any.