mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
more fixes for calendar syncs
This commit is contained in:
parent
c92077926e
commit
9e4fd6183e
@ -14,9 +14,9 @@ namespace Chill\CalendarBundle\Messenger\Handler;
|
|||||||
use Chill\CalendarBundle\Messenger\Message\MSGraphChangeNotificationMessage;
|
use Chill\CalendarBundle\Messenger\Message\MSGraphChangeNotificationMessage;
|
||||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MapCalendarToUser;
|
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MapCalendarToUser;
|
||||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteToLocalSync\CalendarRangeSyncer;
|
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\CalendarRangeRepository;
|
||||||
use Chill\CalendarBundle\Repository\CalendarRepository;
|
use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||||
use Chill\CalendarBundle\Repository\InviteRepository;
|
|
||||||
use Chill\MainBundle\Repository\UserRepository;
|
use Chill\MainBundle\Repository\UserRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@ -35,9 +35,9 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
|
|||||||
|
|
||||||
private CalendarRepository $calendarRepository;
|
private CalendarRepository $calendarRepository;
|
||||||
|
|
||||||
private EntityManagerInterface $em;
|
private CalendarSyncer $calendarSyncer;
|
||||||
|
|
||||||
private InviteRepository $inviteRepository;
|
private EntityManagerInterface $em;
|
||||||
|
|
||||||
private LoggerInterface $logger;
|
private LoggerInterface $logger;
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
|
|||||||
CalendarRangeRepository $calendarRangeRepository,
|
CalendarRangeRepository $calendarRangeRepository,
|
||||||
CalendarRangeSyncer $calendarRangeSyncer,
|
CalendarRangeSyncer $calendarRangeSyncer,
|
||||||
CalendarRepository $calendarRepository,
|
CalendarRepository $calendarRepository,
|
||||||
|
CalendarSyncer $calendarSyncer,
|
||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
InviteRepository $inviteRepository,
|
|
||||||
LoggerInterface $logger,
|
LoggerInterface $logger,
|
||||||
MapCalendarToUser $mapCalendarToUser,
|
MapCalendarToUser $mapCalendarToUser,
|
||||||
UserRepository $userRepository
|
UserRepository $userRepository
|
||||||
@ -58,8 +58,8 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
|
|||||||
$this->calendarRangeRepository = $calendarRangeRepository;
|
$this->calendarRangeRepository = $calendarRangeRepository;
|
||||||
$this->calendarRangeSyncer = $calendarRangeSyncer;
|
$this->calendarRangeSyncer = $calendarRangeSyncer;
|
||||||
$this->calendarRepository = $calendarRepository;
|
$this->calendarRepository = $calendarRepository;
|
||||||
|
$this->calendarSyncer = $calendarSyncer;
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->inviteRepository = $inviteRepository;
|
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->mapCalendarToUser = $mapCalendarToUser;
|
$this->mapCalendarToUser = $mapCalendarToUser;
|
||||||
$this->userRepository = $userRepository;
|
$this->userRepository = $userRepository;
|
||||||
@ -91,14 +91,13 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
|
|||||||
$this->calendarRangeSyncer->handleCalendarRangeSync($calendarRange, $notification, $user);
|
$this->calendarRangeSyncer->handleCalendarRangeSync($calendarRange, $notification, $user);
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
} elseif (null !== $calendar = $this->calendarRepository->findOneBy(['remoteId' => $remoteId])) {
|
} elseif (null !== $calendar = $this->calendarRepository->findOneBy(['remoteId' => $remoteId])) {
|
||||||
$this->remoteToLocalSyncer->handleCalendarSync($calendar, $notification, $user);
|
$this->calendarSyncer->handleCalendarSync($calendar, $notification, $user);
|
||||||
$this->em->flush();
|
|
||||||
} elseif (null !== $invite = $this->inviteRepository->findOneBy(['remoteId' => $remoteId])) {
|
|
||||||
$this->remoteToLocalSyncer->handleInviteSync($invite, $notification, $user);
|
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
} else {
|
} 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class CalendarRangeSyncer
|
|||||||
'remoteEventId' => $notification['resource'],
|
'remoteEventId' => $notification['resource'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return;
|
throw $clientException;
|
||||||
}
|
}
|
||||||
|
|
||||||
$lastModified = RemoteEventConverter::convertStringDateWithTimezone($new['lastModifiedDateTime']);
|
$lastModified = RemoteEventConverter::convertStringDateWithTimezone($new['lastModifiedDateTime']);
|
||||||
|
@ -76,6 +76,8 @@ class CalendarSyncer
|
|||||||
'calendarId' => $calendar->getId(),
|
'calendarId' => $calendar->getId(),
|
||||||
'remoteEventId' => $notification['resource'],
|
'remoteEventId' => $notification['resource'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
throw $clientException;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false === $new['isOrganizer']) {
|
if (false === $new['isOrganizer']) {
|
||||||
@ -142,18 +144,13 @@ class CalendarSyncer
|
|||||||
$invite = $calendar->getInviteForUser($user);
|
$invite = $calendar->getInviteForUser($user);
|
||||||
|
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
// none, organizer, tentativelyAccepted, accepted, declined, notResponded.
|
// possible cases: none, organizer, tentativelyAccepted, accepted, declined, notResponded.
|
||||||
case 'none':
|
case 'none':
|
||||||
case 'notResponded':
|
case 'notResponded':
|
||||||
$invite->setStatus(Invite::PENDING);
|
$invite->setStatus(Invite::PENDING);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'organizer':
|
|
||||||
throw new LogicException('should not happens');
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'tentativelyAccepted':
|
case 'tentativelyAccepted':
|
||||||
$invite->setStatus(Invite::TENTATIVELY_ACCEPTED);
|
$invite->setStatus(Invite::TENTATIVELY_ACCEPTED);
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\GroupCenter;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\ORM\NoResultException;
|
||||||
use Doctrine\ORM\Query\ResultSetMapping;
|
use Doctrine\ORM\Query\ResultSetMapping;
|
||||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
@ -143,11 +144,15 @@ final class UserRepository implements UserRepositoryInterface
|
|||||||
return $this->repository->findOneBy($criteria, $orderBy);
|
return $this->repository->findOneBy($criteria, $orderBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findOneByUsernameOrEmail(string $pattern)
|
public function findOneByUsernameOrEmail(string $pattern): ?User
|
||||||
{
|
{
|
||||||
$qb = $this->queryByUsernameOrEmail($pattern);
|
$qb = $this->queryByUsernameOrEmail($pattern)->select('u');
|
||||||
|
|
||||||
return $qb->getQuery()->getSingleResult();
|
try {
|
||||||
|
return $qb->getQuery()->getSingleResult();
|
||||||
|
} catch (NoResultException $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,7 @@ interface UserRepositoryInterface extends ObjectRepository
|
|||||||
|
|
||||||
public function findOneBy(array $criteria, ?array $orderBy = null): ?User;
|
public function findOneBy(array $criteria, ?array $orderBy = null): ?User;
|
||||||
|
|
||||||
public function findOneByUsernameOrEmail(string $pattern);
|
public function findOneByUsernameOrEmail(string $pattern): ?User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the users having a specific flags.
|
* Get the users having a specific flags.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user