calendarRangeRepository = $calendarRangeRepository; $this->calendarRangeSyncer = $calendarRangeSyncer; $this->calendarRepository = $calendarRepository; $this->em = $em; $this->inviteRepository = $inviteRepository; $this->logger = $logger; $this->mapCalendarToUser = $mapCalendarToUser; $this->userRepository = $userRepository; } public function __invoke(MSGraphChangeNotificationMessage $changeNotificationMessage): void { $user = $this->userRepository->find($changeNotificationMessage->getUserId()); if (null === $user) { $this->logger->warning(__CLASS__ . ' notification concern non-existent user, skipping'); return; } foreach ($changeNotificationMessage->getContent()['value'] as $notification) { $secret = $this->mapCalendarToUser->getSubscriptionSecret($user); if ($secret !== ($notification['clientState'] ?? -1)) { $this->logger->warning(__CLASS__ . ' could not validate secret, skipping'); continue; } $remoteId = $notification['resourceData']['id']; // is this a calendar range ? if (null !== $calendarRange = $this->calendarRangeRepository->findOneBy(['remoteId' => $remoteId])) { $this->calendarRangeSyncer->handleCalendarRangeSync($calendarRange, $notification, $user); $this->em->flush(); } elseif (null !== $calendar = $this->calendarRepository->findOneBy(['remoteId' => $remoteId])) { $this->remoteToLocalSyncer->handleCalendarSync($calendar, $notification, $user); $this->em->flush(); } elseif (null !== $invite = $this->inviteRepository->findOneBy(['remoteId' => $remoteId])) { $this->remoteToLocalSyncer->handleInviteSync($invite, $notification, $user); $this->em->flush(); } else { $this->logger->info(__CLASS__." id not found in any calendar, calendar range nor invite"); } } } }