more fixes for calendar syncs

This commit is contained in:
2022-06-10 14:24:46 +02:00
parent c92077926e
commit 9e4fd6183e
5 changed files with 22 additions and 21 deletions

View File

@@ -14,9 +14,9 @@ namespace Chill\CalendarBundle\Messenger\Handler;
use Chill\CalendarBundle\Messenger\Message\MSGraphChangeNotificationMessage;
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MapCalendarToUser;
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteToLocalSync\CalendarRangeSyncer;
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteToLocalSync\CalendarSyncer;
use Chill\CalendarBundle\Repository\CalendarRangeRepository;
use Chill\CalendarBundle\Repository\CalendarRepository;
use Chill\CalendarBundle\Repository\InviteRepository;
use Chill\MainBundle\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
@@ -35,9 +35,9 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
private CalendarRepository $calendarRepository;
private EntityManagerInterface $em;
private CalendarSyncer $calendarSyncer;
private InviteRepository $inviteRepository;
private EntityManagerInterface $em;
private LoggerInterface $logger;
@@ -49,8 +49,8 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
CalendarRangeRepository $calendarRangeRepository,
CalendarRangeSyncer $calendarRangeSyncer,
CalendarRepository $calendarRepository,
CalendarSyncer $calendarSyncer,
EntityManagerInterface $em,
InviteRepository $inviteRepository,
LoggerInterface $logger,
MapCalendarToUser $mapCalendarToUser,
UserRepository $userRepository
@@ -58,8 +58,8 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
$this->calendarRangeRepository = $calendarRangeRepository;
$this->calendarRangeSyncer = $calendarRangeSyncer;
$this->calendarRepository = $calendarRepository;
$this->calendarSyncer = $calendarSyncer;
$this->em = $em;
$this->inviteRepository = $inviteRepository;
$this->logger = $logger;
$this->mapCalendarToUser = $mapCalendarToUser;
$this->userRepository = $userRepository;
@@ -91,14 +91,13 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
$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->calendarSyncer->handleCalendarSync($calendar, $notification, $user);
$this->em->flush();
} else {
$this->logger->info(__CLASS__ . ' id not found in any calendar, calendar range nor invite');
$this->logger->info(__CLASS__ . ' id not found in any calendar nor calendar range');
}
}
$this->em->flush();
}
}