From 6e48a042b3828717fb824a6adbb174d427df3f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 9 Jun 2022 15:44:48 +0200 Subject: [PATCH] prevent change when syncing from remote --- .../MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php | 6 ++++-- .../Connector/MSGraph/CalendarRangeSyncerTest.php | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php index 29d06784c..39ea2a32a 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/RemoteToLocalSync/CalendarRangeSyncer.php @@ -11,7 +11,6 @@ declare(strict_types=1); namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteToLocalSync; -use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Entity\CalendarRange; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MachineHttpClient; use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteEventConverter; @@ -53,6 +52,7 @@ class CalendarRangeSyncer if (null !== $calendarRange->getCalendar()) { return; } + $calendarRange->preventEnqueueChanges = true; $this->logger->info(__CLASS__ . ' remove a calendar range because deleted on remote calendar'); $this->em->remove($calendarRange); @@ -91,7 +91,9 @@ class CalendarRangeSyncer ->addRemoteAttributes([ 'lastModifiedDateTime' => $lastModified->getTimestamp(), 'changeKey' => $new['changeKey'], - ]); + ]) + ->preventEnqueueChanges = true + ; } } } diff --git a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarRangeSyncerTest.php b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarRangeSyncerTest.php index ba6938821..af2009fad 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarRangeSyncerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/RemoteCalendar/Connector/MSGraph/CalendarRangeSyncerTest.php @@ -167,6 +167,7 @@ JSON; $calendarRange->getStartDate()->format(\DateTimeImmutable::ATOM)); $this->assertStringContainsString('2022-06-10T17:30:00', $calendarRange->getEndDate()->format(\DateTimeImmutable::ATOM)); + $this->assertTrue($calendarRange->preventEnqueueChanges); } public function testDeleteCalendarRangeWithoutAssociation(): void @@ -194,6 +195,7 @@ JSON; $calendarRange, $notification['value'][0], $user); + $this->assertTrue($calendarRange->preventEnqueueChanges); } public function testDeleteCalendarRangeWithAssociation(): void @@ -224,5 +226,6 @@ JSON; $calendarRange, $notification['value'][0], $user); + } }