mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
calendar range: remove on remote after removal in the database
This commit is contained in:
@@ -45,6 +45,7 @@ class MachineHttpClient implements HttpClientInterface
|
||||
switch ($method) {
|
||||
case 'GET':
|
||||
case 'HEAD':
|
||||
case 'DELETE':
|
||||
$options['headers']['Accept'] = 'application/json';
|
||||
|
||||
break;
|
||||
|
@@ -106,6 +106,15 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void
|
||||
{
|
||||
if ('' === $remoteId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->removeEvent($remoteId, $user);
|
||||
}
|
||||
|
||||
public function syncCalendarRange(CalendarRange $calendarRange): void
|
||||
{
|
||||
if ($calendarRange->hasRemoteId()) {
|
||||
@@ -200,6 +209,23 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
);
|
||||
}
|
||||
|
||||
private function removeEvent($remoteId, User $user): void
|
||||
{
|
||||
$userId = $this->mapCalendarToUser->getUserId($user);
|
||||
|
||||
try {
|
||||
$this->machineHttpClient->request(
|
||||
'DELETE',
|
||||
'users/' . $userId . '/calendar/events/' . $remoteId
|
||||
);
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
$this->logger->warning('could not remove event from calendar', [
|
||||
'event_remote_id' => $remoteId,
|
||||
'user_id' => $user->getId(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function updateRemoteCalendarRange(CalendarRange $calendarRange): void
|
||||
{
|
||||
$userId = $this->mapCalendarToUser->getUserId($calendarRange->getUser());
|
||||
|
@@ -34,6 +34,10 @@ class NullRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
return [];
|
||||
}
|
||||
|
||||
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void
|
||||
{
|
||||
}
|
||||
|
||||
public function syncCalendarRange(CalendarRange $calendarRange): void
|
||||
{
|
||||
}
|
||||
|
@@ -37,5 +37,7 @@ interface RemoteCalendarConnectorInterface
|
||||
*/
|
||||
public function listEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): array;
|
||||
|
||||
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void;
|
||||
|
||||
public function syncCalendarRange(CalendarRange $calendarRange): void;
|
||||
}
|
||||
|
Reference in New Issue
Block a user