small fixes on sync from remote

This commit is contained in:
2022-06-09 17:06:57 +02:00
parent 6e48a042b3
commit f149b24802
5 changed files with 317 additions and 2 deletions

View File

@@ -23,6 +23,8 @@ use Psr\Log\LoggerInterface;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
/**
* Handle notification of chagnes from MSGraph
*
* @AsMessageHandler
*/
class MSGraphChangeNotificationHandler implements MessageHandlerInterface
@@ -43,6 +45,26 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
private UserRepository $userRepository;
public function __construct(
CalendarRangeRepository $calendarRangeRepository,
CalendarRangeSyncer $calendarRangeSyncer,
CalendarRepository $calendarRepository,
EntityManagerInterface $em,
InviteRepository $inviteRepository,
LoggerInterface $logger,
MapCalendarToUser $mapCalendarToUser,
UserRepository $userRepository
) {
$this->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());
@@ -74,6 +96,8 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
} 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");
}
}
}