From d512a5629ec01fecd87944836eb9b02eb11257b8 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 7 May 2021 10:26:49 +0200 Subject: [PATCH 1/4] Remove the \OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject event Signed-off-by: Christoph Wurst --- .../composer/composer/autoload_classmap.php | 4 +- .../dav/composer/composer/autoload_static.php | 4 +- apps/dav/lib/AppInfo/Application.php | 14 ++--- apps/dav/lib/CalDAV/CalDavBackend.php | 9 --- ...stener.php => ActivityUpdaterListener.php} | 55 +++++++++++------- ...CalendarObjectReminderUpdaterListener.php} | 57 ++++++++++++------- .../tests/unit/CalDAV/CalDavBackendTest.php | 32 +++++++---- 7 files changed, 102 insertions(+), 73 deletions(-) rename apps/dav/lib/Listener/{CalendarDeletionActivityUpdaterListener.php => ActivityUpdaterListener.php} (53%) rename apps/dav/lib/Listener/{CalendarDeletionReminderUpdaterListener.php => CalendarObjectReminderUpdaterListener.php} (51%) diff --git a/apps/dav/composer/composer/autoload_classmap.php b/apps/dav/composer/composer/autoload_classmap.php index fe6c6ab325..5da3526c82 100644 --- a/apps/dav/composer/composer/autoload_classmap.php +++ b/apps/dav/composer/composer/autoload_classmap.php @@ -205,10 +205,10 @@ return array( 'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => $baseDir . '/../lib/Files/Sharing/FilesDropPlugin.php', 'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => $baseDir . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php', 'OCA\\DAV\\HookManager' => $baseDir . '/../lib/HookManager.php', + 'OCA\\DAV\\Listener\\ActivityUpdaterListener' => $baseDir . '/../lib/Listener/ActivityUpdaterListener.php', 'OCA\\DAV\\Listener\\CalendarContactInteractionListener' => $baseDir . '/../lib/Listener/CalendarContactInteractionListener.php', - 'OCA\\DAV\\Listener\\CalendarDeletionActivityUpdaterListener' => $baseDir . '/../lib/Listener/CalendarDeletionActivityUpdaterListener.php', 'OCA\\DAV\\Listener\\CalendarDeletionDefaultUpdaterListener' => $baseDir . '/../lib/Listener/CalendarDeletionDefaultUpdaterListener.php', - 'OCA\\DAV\\Listener\\CalendarDeletionReminderUpdaterListener' => $baseDir . '/../lib/Listener/CalendarDeletionReminderUpdaterListener.php', + 'OCA\\DAV\\Listener\\CalendarObjectReminderUpdaterListener' => $baseDir . '/../lib/Listener/CalendarObjectReminderUpdaterListener.php', 'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndex.php', 'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php', 'OCA\\DAV\\Migration\\BuildSocialSearchIndex' => $baseDir . '/../lib/Migration/BuildSocialSearchIndex.php', diff --git a/apps/dav/composer/composer/autoload_static.php b/apps/dav/composer/composer/autoload_static.php index 48e453b72f..60162ba555 100644 --- a/apps/dav/composer/composer/autoload_static.php +++ b/apps/dav/composer/composer/autoload_static.php @@ -220,10 +220,10 @@ class ComposerStaticInitDAV 'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/FilesDropPlugin.php', 'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php', 'OCA\\DAV\\HookManager' => __DIR__ . '/..' . '/../lib/HookManager.php', + 'OCA\\DAV\\Listener\\ActivityUpdaterListener' => __DIR__ . '/..' . '/../lib/Listener/ActivityUpdaterListener.php', 'OCA\\DAV\\Listener\\CalendarContactInteractionListener' => __DIR__ . '/..' . '/../lib/Listener/CalendarContactInteractionListener.php', - 'OCA\\DAV\\Listener\\CalendarDeletionActivityUpdaterListener' => __DIR__ . '/..' . '/../lib/Listener/CalendarDeletionActivityUpdaterListener.php', 'OCA\\DAV\\Listener\\CalendarDeletionDefaultUpdaterListener' => __DIR__ . '/..' . '/../lib/Listener/CalendarDeletionDefaultUpdaterListener.php', - 'OCA\\DAV\\Listener\\CalendarDeletionReminderUpdaterListener' => __DIR__ . '/..' . '/../lib/Listener/CalendarDeletionReminderUpdaterListener.php', + 'OCA\\DAV\\Listener\\CalendarObjectReminderUpdaterListener' => __DIR__ . '/..' . '/../lib/Listener/CalendarObjectReminderUpdaterListener.php', 'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndex.php', 'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php', 'OCA\\DAV\\Migration\\BuildSocialSearchIndex' => __DIR__ . '/..' . '/../lib/Migration/BuildSocialSearchIndex.php', diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 8298a9dd6f..8bedb28714 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -54,13 +54,14 @@ use OCA\DAV\CardDAV\PhotoCache; use OCA\DAV\CardDAV\SyncService; use OCA\DAV\Events\CalendarDeletedEvent; use OCA\DAV\Events\CalendarObjectCreatedEvent; +use OCA\DAV\Events\CalendarObjectDeletedEvent; use OCA\DAV\Events\CalendarObjectUpdatedEvent; use OCA\DAV\Events\CalendarShareUpdatedEvent; use OCA\DAV\HookManager; +use OCA\DAV\Listener\ActivityUpdaterListener; use OCA\DAV\Listener\CalendarContactInteractionListener; -use OCA\DAV\Listener\CalendarDeletionActivityUpdaterListener; use OCA\DAV\Listener\CalendarDeletionDefaultUpdaterListener; -use OCA\DAV\Listener\CalendarDeletionReminderUpdaterListener; +use OCA\DAV\Listener\CalendarObjectReminderUpdaterListener; use OCA\DAV\Search\ContactsSearchProvider; use OCA\DAV\Search\EventsSearchProvider; use OCA\DAV\Search\TasksSearchProvider; @@ -114,11 +115,13 @@ class Application extends App implements IBootstrap { /** * Register event listeners */ - $context->registerEventListener(CalendarDeletedEvent::class, CalendarDeletionActivityUpdaterListener::class); - $context->registerEventListener(CalendarDeletedEvent::class, CalendarDeletionReminderUpdaterListener::class); + $context->registerEventListener(CalendarDeletedEvent::class, ActivityUpdaterListener::class); + $context->registerEventListener(CalendarDeletedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarDeletedEvent::class, CalendarDeletionDefaultUpdaterListener::class); $context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarContactInteractionListener::class); $context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarContactInteractionListener::class); + $context->registerEventListener(CalendarObjectDeletedEvent::class, ActivityUpdaterListener::class); + $context->registerEventListener(CalendarObjectDeletedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarShareUpdatedEvent::class, CalendarContactInteractionListener::class); $context->registerNotifierService(Notifier::class); @@ -237,8 +240,6 @@ class Application extends App implements IBootstrap { $subject = Event::SUBJECT_OBJECT_ADD; if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject') { $subject = Event::SUBJECT_OBJECT_UPDATE; - } elseif ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject') { - $subject = Event::SUBJECT_OBJECT_DELETE; } $backend->onTouchCalendarObject( $subject, @@ -257,7 +258,6 @@ class Application extends App implements IBootstrap { }; $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener); $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener); - $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', $listener); $dispatcher->addListener('OCP\Federation\TrustedServerEvent::remove', function (GenericEvent $event) { diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index fb99040dd6..b4782ca684 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1278,15 +1278,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $shares = $this->getShares($calendarId); $this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent((int)$calendarId, $calendarRow, $shares, $data)); - $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', new GenericEvent( - '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', - [ - 'calendarId' => $calendarId, - 'calendarData' => $calendarRow, - 'shares' => $shares, - 'objectData' => $data, - ] - )); } else { $subscriptionRow = $this->getSubscriptionById($calendarId); diff --git a/apps/dav/lib/Listener/CalendarDeletionActivityUpdaterListener.php b/apps/dav/lib/Listener/ActivityUpdaterListener.php similarity index 53% rename from apps/dav/lib/Listener/CalendarDeletionActivityUpdaterListener.php rename to apps/dav/lib/Listener/ActivityUpdaterListener.php index 4139aba226..9734a4fead 100644 --- a/apps/dav/lib/Listener/CalendarDeletionActivityUpdaterListener.php +++ b/apps/dav/lib/Listener/ActivityUpdaterListener.php @@ -27,16 +27,14 @@ namespace OCA\DAV\Listener; use OCA\DAV\CalDAV\Activity\Backend as ActivityBackend; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarObjectDeletedEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use Psr\Log\LoggerInterface; use Throwable; use function sprintf; -/** - * @template-implements IEventListener<\OCA\DAV\Events\CalendarDeletedEvent> - */ -class CalendarDeletionActivityUpdaterListener implements IEventListener { +class ActivityUpdaterListener implements IEventListener { /** @var ActivityBackend */ private $activityBackend; @@ -51,25 +49,40 @@ class CalendarDeletionActivityUpdaterListener implements IEventListener { } public function handle(Event $event): void { - if (!($event instanceof CalendarDeletedEvent)) { - // Not what we subscribed to - return; - } + if ($event instanceof CalendarDeletedEvent) { + try { + $this->activityBackend->onCalendarDelete( + $event->getCalendarData(), + $event->getShares() + ); - try { - $this->activityBackend->onCalendarDelete( - $event->getCalendarData(), - $event->getShares() - ); + $this->logger->debug( + sprintf('Activity generated for deleted calendar %d', $event->getCalendarId()) + ); + } catch (Throwable $e) { + // Any error with activities shouldn't abort the calendar deletion, so we just log it + $this->logger->error('Error generating activities for a deleted calendar: ' . $e->getMessage(), [ + 'exception' => $e, + ]); + } + } elseif ($event instanceof CalendarObjectDeletedEvent) { + try { + $this->activityBackend->onTouchCalendarObject( + \OCA\DAV\CalDAV\Activity\Provider\Event::SUBJECT_OBJECT_DELETE, + $event->getCalendarData(), + $event->getShares(), + $event->getObjectData() + ); - $this->logger->debug( - sprintf('Activity generated for deleted calendar %d', $event->getCalendarId()) - ); - } catch (Throwable $e) { - // Any error with activities shouldn't abort the calendar deletion, so we just log it - $this->logger->error('Error generating activities for a deleted calendar: ' . $e->getMessage(), [ - 'exception' => $e, - ]); + $this->logger->debug( + sprintf('Activity generated for deleted calendar object %d', $event->getCalendarId()) + ); + } catch (Throwable $e) { + // Any error with activities shouldn't abort the calendar deletion, so we just log it + $this->logger->error('Error generating activity for a deleted calendar object: ' . $e->getMessage(), [ + 'exception' => $e, + ]); + } } } } diff --git a/apps/dav/lib/Listener/CalendarDeletionReminderUpdaterListener.php b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php similarity index 51% rename from apps/dav/lib/Listener/CalendarDeletionReminderUpdaterListener.php rename to apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php index 3beecc8ff0..63fe786cfa 100644 --- a/apps/dav/lib/Listener/CalendarDeletionReminderUpdaterListener.php +++ b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php @@ -26,49 +26,66 @@ declare(strict_types=1); namespace OCA\DAV\Listener; use OCA\DAV\CalDAV\Reminder\Backend as ReminderBackend; +use OCA\DAV\CalDAV\Reminder\ReminderService; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarObjectDeletedEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use Psr\Log\LoggerInterface; use Throwable; use function sprintf; -/** - * @template-implements IEventListener<\OCA\DAV\Events\CalendarDeletedEvent> - */ -class CalendarDeletionReminderUpdaterListener implements IEventListener { +class CalendarObjectReminderUpdaterListener implements IEventListener { /** @var ReminderBackend */ private $reminderBackend; + /** @var ReminderService */ + private $reminderService; + /** @var LoggerInterface */ private $logger; public function __construct(ReminderBackend $reminderBackend, + ReminderService $reminderService, LoggerInterface $logger) { $this->reminderBackend = $reminderBackend; + $this->reminderService = $reminderService; $this->logger = $logger; } public function handle(Event $event): void { - if (!($event instanceof CalendarDeletedEvent)) { - // Not what we subscribed to - return; - } + if ($event instanceof CalendarDeletedEvent) { + try { + $this->reminderBackend->cleanRemindersForCalendar( + $event->getCalendarId() + ); - try { - $this->reminderBackend->cleanRemindersForCalendar( - $event->getCalendarId() - ); + $this->logger->debug( + sprintf('Reminders of calendar %d cleaned up', $event->getCalendarId()) + ); + } catch (Throwable $e) { + // Any error with activities shouldn't abort the calendar deletion, so we just log it + $this->logger->error('Error cleaning up reminders of a deleted calendar: ' . $e->getMessage(), [ + 'exception' => $e, + ]); + } + } elseif ($event instanceof CalendarObjectDeletedEvent) { + try { + $this->reminderService->onTouchCalendarObject( + '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', + $event->getObjectData() + ); - $this->logger->debug( - sprintf('Reminders of calendar %d cleaned up', $event->getCalendarId()) - ); - } catch (Throwable $e) { - // Any error with activities shouldn't abort the calendar deletion, so we just log it - $this->logger->error('Error cleaning up reminders of a deleted calendar: ' . $e->getMessage(), [ - 'exception' => $e, - ]); + $this->logger->debug( + sprintf('Reminders of calendar object of calendar %d cleaned up', $event->getCalendarId()) + ); + } catch (Throwable $e) { + // Any error with activities shouldn't abort the calendar object deletion, so we just log it + $this->logger->error('Error cleaning up reminders of a deleted calendar object: ' . $e->getMessage(), [ + 'exception' => $e, + ]); + } } } } diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 25966aa5c9..98e1b728f9 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -278,9 +278,11 @@ EOD; $this->assertEquals($calData, $calendarObject['calendardata']); // delete the card - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarDeletedEvent; + })); $this->backend->deleteCalendarObject($calendarId, $uri); $calendarObjects = $this->backend->getCalendarObjects($calendarId); $this->assertCount(0, $calendarObjects); @@ -412,17 +414,23 @@ EOD; $this->assertEquals($calData[2], $calendarObjects[1]['calendardata']); // delete the card - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarDeletedEvent; + })); $this->backend->deleteCalendarObject($calendarId, $uri0); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarDeletedEvent; + })); $this->backend->deleteCalendarObject($calendarId, $uri1); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarDeletedEvent; + })); $this->backend->deleteCalendarObject($calendarId, $uri2); $calendarObjects = $this->backend->getCalendarObjects($calendarId); $this->assertCount(0, $calendarObjects); From f808267949e5513188961ca5f6fc38d57f6c7fd1 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 7 May 2021 11:19:45 +0200 Subject: [PATCH 2/4] Remove the \OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject event Signed-off-by: Christoph Wurst --- apps/dav/lib/AppInfo/Application.php | 13 ++++++------- apps/dav/lib/CalDAV/CalDavBackend.php | 9 --------- .../lib/Listener/ActivityUpdaterListener.php | 19 +++++++++++++++++++ .../CalendarObjectReminderUpdaterListener.php | 17 +++++++++++++++++ .../tests/unit/CalDAV/CalDavBackendTest.php | 9 ++++++--- 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 8bedb28714..a5444bb20d 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -118,8 +118,12 @@ class Application extends App implements IBootstrap { $context->registerEventListener(CalendarDeletedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarDeletedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarDeletedEvent::class, CalendarDeletionDefaultUpdaterListener::class); + $context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarContactInteractionListener::class); + + $context->registerEventListener(CalendarObjectUpdatedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarContactInteractionListener::class); + $context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarObjectDeletedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectDeletedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarShareUpdatedEvent::class, CalendarContactInteractionListener::class); @@ -237,12 +241,8 @@ class Application extends App implements IBootstrap { /** @var Backend $backend */ $backend = $container->query(Backend::class); - $subject = Event::SUBJECT_OBJECT_ADD; - if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject') { - $subject = Event::SUBJECT_OBJECT_UPDATE; - } $backend->onTouchCalendarObject( - $subject, + Event::SUBJECT_OBJECT_ADD, $event->getArgument('calendarData'), $event->getArgument('shares'), $event->getArgument('objectData') @@ -257,7 +257,6 @@ class Application extends App implements IBootstrap { ); }; $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener); - $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener); $dispatcher->addListener('OCP\Federation\TrustedServerEvent::remove', function (GenericEvent $event) { @@ -380,4 +379,4 @@ class Application extends App implements IBootstrap { $logger->logException($ex); } } -} +} \ No newline at end of file diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index b4782ca684..058d4422d6 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1215,15 +1215,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $shares = $this->getShares($calendarId); $this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow)); - $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', new GenericEvent( - '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', - [ - 'calendarId' => $calendarId, - 'calendarData' => $calendarRow, - 'shares' => $shares, - 'objectData' => $objectRow, - ] - )); } else { $subscriptionRow = $this->getSubscriptionById($calendarId); diff --git a/apps/dav/lib/Listener/ActivityUpdaterListener.php b/apps/dav/lib/Listener/ActivityUpdaterListener.php index 9734a4fead..962fa239af 100644 --- a/apps/dav/lib/Listener/ActivityUpdaterListener.php +++ b/apps/dav/lib/Listener/ActivityUpdaterListener.php @@ -28,6 +28,7 @@ namespace OCA\DAV\Listener; use OCA\DAV\CalDAV\Activity\Backend as ActivityBackend; use OCA\DAV\Events\CalendarDeletedEvent; use OCA\DAV\Events\CalendarObjectDeletedEvent; +use OCA\DAV\Events\CalendarObjectUpdatedEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use Psr\Log\LoggerInterface; @@ -65,6 +66,24 @@ class ActivityUpdaterListener implements IEventListener { 'exception' => $e, ]); } + } elseif ($event instanceof CalendarObjectUpdatedEvent) { + try { + $this->activityBackend->onTouchCalendarObject( + \OCA\DAV\CalDAV\Activity\Provider\Event::SUBJECT_OBJECT_UPDATE, + $event->getCalendarData(), + $event->getShares(), + $event->getObjectData() + ); + + $this->logger->debug( + sprintf('Activity generated for deleted calendar object %d', $event->getCalendarId()) + ); + } catch (Throwable $e) { + // Any error with activities shouldn't abort the calendar deletion, so we just log it + $this->logger->error('Error generating activity for a deleted calendar object: ' . $e->getMessage(), [ + 'exception' => $e, + ]); + } } elseif ($event instanceof CalendarObjectDeletedEvent) { try { $this->activityBackend->onTouchCalendarObject( diff --git a/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php index 63fe786cfa..8261b68af4 100644 --- a/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php +++ b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php @@ -29,6 +29,7 @@ use OCA\DAV\CalDAV\Reminder\Backend as ReminderBackend; use OCA\DAV\CalDAV\Reminder\ReminderService; use OCA\DAV\Events\CalendarDeletedEvent; use OCA\DAV\Events\CalendarObjectDeletedEvent; +use OCA\DAV\Events\CalendarObjectUpdatedEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use Psr\Log\LoggerInterface; @@ -70,6 +71,22 @@ class CalendarObjectReminderUpdaterListener implements IEventListener { 'exception' => $e, ]); } + } elseif ($event instanceof CalendarObjectUpdatedEvent) { + try { + $this->reminderService->onTouchCalendarObject( + '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', + $event->getObjectData() + ); + + $this->logger->debug( + sprintf('Reminders of calendar object of calendar %d cleaned up', $event->getCalendarId()) + ); + } catch (Throwable $e) { + // Any error with activities shouldn't abort the calendar object deletion, so we just log it + $this->logger->error('Error cleaning up reminders of a calendar object: ' . $e->getMessage(), [ + 'exception' => $e, + ]); + } } elseif ($event instanceof CalendarObjectDeletedEvent) { try { $this->reminderService->onTouchCalendarObject( diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 98e1b728f9..96ae4312fd 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -37,6 +37,7 @@ use DateTimeZone; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\Calendar; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarUpdatedEvent; use OCP\IConfig; use OCP\IL10N; use Sabre\DAV\Exception\NotFound; @@ -270,9 +271,11 @@ DTEND;VALUE=DATE-TIME:20130912T140000Z END:VEVENT END:VCALENDAR EOD; - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarUpdatedEvent; + })); $this->backend->updateCalendarObject($calendarId, $uri, $calData); $calendarObject = $this->backend->getCalendarObject($calendarId, $uri); $this->assertEquals($calData, $calendarObject['calendardata']); From 257613e6efd429dd1c6cde4abbcbb590d32408e8 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 7 May 2021 11:36:23 +0200 Subject: [PATCH 3/4] Remove the \OCA\DAV\CalDAV\CalDavBackend::createCalendarObject event Signed-off-by: Christoph Wurst --- apps/dav/lib/AppInfo/Application.php | 29 ++----------- apps/dav/lib/CalDAV/CalDavBackend.php | 9 ---- .../lib/Listener/ActivityUpdaterListener.php | 19 +++++++++ .../CalendarObjectReminderUpdaterListener.php | 17 ++++++++ .../unit/CalDAV/AbstractCalDavBackend.php | 9 ++-- .../tests/unit/CalDAV/CalDavBackendTest.php | 41 ++++++++++++------- 6 files changed, 72 insertions(+), 52 deletions(-) diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index a5444bb20d..19c360e708 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -36,7 +36,6 @@ namespace OCA\DAV\AppInfo; use Exception; use OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob; use OCA\DAV\CalDAV\Activity\Backend; -use OCA\DAV\CalDAV\Activity\Provider\Event; use OCA\DAV\CalDAV\BirthdayService; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\CalendarManager; @@ -45,7 +44,7 @@ use OCA\DAV\CalDAV\Reminder\NotificationProvider\EmailProvider; use OCA\DAV\CalDAV\Reminder\NotificationProvider\PushProvider; use OCA\DAV\CalDAV\Reminder\NotificationProviderManager; use OCA\DAV\CalDAV\Reminder\Notifier; -use OCA\DAV\CalDAV\Reminder\ReminderService; + use OCA\DAV\CalDAV\WebcalCaching\RefreshWebcalService; use OCA\DAV\Capabilities; use OCA\DAV\CardDAV\CardDavBackend; @@ -118,9 +117,9 @@ class Application extends App implements IBootstrap { $context->registerEventListener(CalendarDeletedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarDeletedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarDeletedEvent::class, CalendarDeletionDefaultUpdaterListener::class); - + $context->registerEventListener(CalendarObjectCreatedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarContactInteractionListener::class); - + $context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarObjectReminderUpdaterListener::class); $context->registerEventListener(CalendarObjectUpdatedEvent::class, ActivityUpdaterListener::class); $context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarContactInteractionListener::class); $context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarObjectReminderUpdaterListener::class); @@ -237,26 +236,6 @@ class Application extends App implements IBootstrap { ); }); - $listener = function (GenericEvent $event, $eventName) use ($container): void { - /** @var Backend $backend */ - $backend = $container->query(Backend::class); - - $backend->onTouchCalendarObject( - Event::SUBJECT_OBJECT_ADD, - $event->getArgument('calendarData'), - $event->getArgument('shares'), - $event->getArgument('objectData') - ); - - /** @var ReminderService $reminderBackend */ - $reminderService = $container->query(ReminderService::class); - - $reminderService->onTouchCalendarObject( - $eventName, - $event->getArgument('objectData') - ); - }; - $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener); $dispatcher->addListener('OCP\Federation\TrustedServerEvent::remove', function (GenericEvent $event) { @@ -379,4 +358,4 @@ class Application extends App implements IBootstrap { $logger->logException($ex); } } -} \ No newline at end of file +} diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 058d4422d6..99504c4b5f 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1141,15 +1141,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $shares = $this->getShares($calendarId); $this->dispatcher->dispatchTyped(new CalendarObjectCreatedEvent((int)$calendarId, $calendarRow, $shares, $objectRow)); - $this->legacyDispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', new GenericEvent( - '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', - [ - 'calendarId' => $calendarId, - 'calendarData' => $calendarRow, - 'shares' => $shares, - 'objectData' => $objectRow, - ] - )); } else { $subscriptionRow = $this->getSubscriptionById($calendarId); diff --git a/apps/dav/lib/Listener/ActivityUpdaterListener.php b/apps/dav/lib/Listener/ActivityUpdaterListener.php index 962fa239af..8ff65170e3 100644 --- a/apps/dav/lib/Listener/ActivityUpdaterListener.php +++ b/apps/dav/lib/Listener/ActivityUpdaterListener.php @@ -27,6 +27,7 @@ namespace OCA\DAV\Listener; use OCA\DAV\CalDAV\Activity\Backend as ActivityBackend; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarObjectCreatedEvent; use OCA\DAV\Events\CalendarObjectDeletedEvent; use OCA\DAV\Events\CalendarObjectUpdatedEvent; use OCP\EventDispatcher\Event; @@ -66,6 +67,24 @@ class ActivityUpdaterListener implements IEventListener { 'exception' => $e, ]); } + } elseif ($event instanceof CalendarObjectCreatedEvent) { + try { + $this->activityBackend->onTouchCalendarObject( + \OCA\DAV\CalDAV\Activity\Provider\Event::SUBJECT_OBJECT_ADD, + $event->getCalendarData(), + $event->getShares(), + $event->getObjectData() + ); + + $this->logger->debug( + sprintf('Activity generated for new calendar object in calendar %d', $event->getCalendarId()) + ); + } catch (Throwable $e) { + // Any error with activities shouldn't abort the calendar object creation, so we just log it + $this->logger->error('Error generating activity for a new calendar object: ' . $e->getMessage(), [ + 'exception' => $e, + ]); + } } elseif ($event instanceof CalendarObjectUpdatedEvent) { try { $this->activityBackend->onTouchCalendarObject( diff --git a/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php index 8261b68af4..4c201a19c3 100644 --- a/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php +++ b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php @@ -28,6 +28,7 @@ namespace OCA\DAV\Listener; use OCA\DAV\CalDAV\Reminder\Backend as ReminderBackend; use OCA\DAV\CalDAV\Reminder\ReminderService; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarObjectCreatedEvent; use OCA\DAV\Events\CalendarObjectDeletedEvent; use OCA\DAV\Events\CalendarObjectUpdatedEvent; use OCP\EventDispatcher\Event; @@ -71,6 +72,22 @@ class CalendarObjectReminderUpdaterListener implements IEventListener { 'exception' => $e, ]); } + } elseif ($event instanceof CalendarObjectCreatedEvent) { + try { + $this->reminderService->onTouchCalendarObject( + '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', + $event->getObjectData() + ); + + $this->logger->debug( + sprintf('Reminders of calendar object of calendar %d created', $event->getCalendarId()) + ); + } catch (Throwable $e) { + // Any error with reminders shouldn't abort the calendar object creation, so we just log it + $this->logger->error('Error creating reminders of a calendar object: ' . $e->getMessage(), [ + 'exception' => $e, + ]); + } } elseif ($event instanceof CalendarObjectUpdatedEvent) { try { $this->reminderService->onTouchCalendarObject( diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php index b512847a7e..17ac839b5f 100644 --- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php +++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php @@ -32,6 +32,7 @@ use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\Proxy\ProxyMapper; use OCA\DAV\Connector\Sabre\Principal; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarObjectCreatedEvent; use OCP\App\IAppManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; @@ -206,9 +207,11 @@ END:VCALENDAR EOD; $uri0 = $this->getUniqueID('event'); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri0, $calData); diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 96ae4312fd..097fbd79fe 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -37,6 +37,7 @@ use DateTimeZone; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\Calendar; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarObjectCreatedEvent; use OCA\DAV\Events\CalendarUpdatedEvent; use OCP\IConfig; use OCP\IL10N; @@ -187,9 +188,11 @@ END:VEVENT END:VCALENDAR EOD; - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri, $calData); /** @var IACL $child */ @@ -233,9 +236,11 @@ END:VEVENT END:VCALENDAR EOD; - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri, $calData); // get all the cards @@ -378,19 +383,25 @@ END:VCALENDAR EOD; $uri0 = static::getUniqueID('card'); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri0, $calData[0]); $uri1 = static::getUniqueID('card'); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri1, $calData[1]); $uri2 = static::getUniqueID('card'); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri2, $calData[2]); // get all the cards From f5462650f1480bf23a58285e0e4476957a0720db Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 7 May 2021 11:43:31 +0200 Subject: [PATCH 4/4] Clean up reminder actions and call methods directly Signed-off-by: Christoph Wurst --- .../BuildReminderIndexBackgroundJob.php | 2 +- .../lib/CalDAV/Reminder/ReminderService.php | 38 ++++++------------- .../CalendarObjectReminderUpdaterListener.php | 9 ++--- .../CalDAV/Reminder/ReminderServiceTest.php | 18 +++------ 4 files changed, 21 insertions(+), 46 deletions(-) diff --git a/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php b/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php index ad5bf7736a..badfc2ca04 100644 --- a/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php +++ b/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php @@ -125,7 +125,7 @@ class BuildReminderIndexBackgroundJob extends QueuedJob { $row['component'] = $row['componenttype']; try { - $this->reminderService->onTouchCalendarObject('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $row); + $this->reminderService->onCalendarObjectCreate($row); } catch (\Exception $ex) { $this->logger->logException($ex); } diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index 9c27231cb8..83fe413c0e 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -44,6 +44,7 @@ use Sabre\VObject\InvalidDataException; use Sabre\VObject\ParseException; use Sabre\VObject\Recur\EventIterator; use Sabre\VObject\Recur\NoInstancesException; +use function strcasecmp; class ReminderService { @@ -154,39 +155,15 @@ class ReminderService { } /** - * @param string $action * @param array $objectData * @throws VObject\InvalidDataException */ - public function onTouchCalendarObject(string $action, - array $objectData):void { + public function onCalendarObjectCreate(array $objectData):void { // We only support VEvents for now if (strcasecmp($objectData['component'], 'vevent') !== 0) { return; } - switch ($action) { - case '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject': - $this->onCalendarObjectCreate($objectData); - break; - - case '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject': - $this->onCalendarObjectEdit($objectData); - break; - - case '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject': - $this->onCalendarObjectDelete($objectData); - break; - - default: - break; - } - } - - /** - * @param array $objectData - */ - private function onCalendarObjectCreate(array $objectData):void { $calendarData = is_resource($objectData['calendardata']) ? stream_get_contents($objectData['calendardata']) : $objectData['calendardata']; @@ -307,8 +284,9 @@ class ReminderService { /** * @param array $objectData + * @throws VObject\InvalidDataException */ - private function onCalendarObjectEdit(array $objectData):void { + public function onCalendarObjectEdit(array $objectData):void { // TODO - this can be vastly improved // - get cached reminders // - ... @@ -319,8 +297,14 @@ class ReminderService { /** * @param array $objectData + * @throws VObject\InvalidDataException */ - private function onCalendarObjectDelete(array $objectData):void { + public function onCalendarObjectDelete(array $objectData):void { + // We only support VEvents for now + if (strcasecmp($objectData['component'], 'vevent') !== 0) { + return; + } + $this->backend->cleanRemindersForEvent((int) $objectData['id']); } diff --git a/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php index 4c201a19c3..b976ef3ad9 100644 --- a/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php +++ b/apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php @@ -74,8 +74,7 @@ class CalendarObjectReminderUpdaterListener implements IEventListener { } } elseif ($event instanceof CalendarObjectCreatedEvent) { try { - $this->reminderService->onTouchCalendarObject( - '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', + $this->reminderService->onCalendarObjectCreate( $event->getObjectData() ); @@ -90,8 +89,7 @@ class CalendarObjectReminderUpdaterListener implements IEventListener { } } elseif ($event instanceof CalendarObjectUpdatedEvent) { try { - $this->reminderService->onTouchCalendarObject( - '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', + $this->reminderService->onCalendarObjectEdit( $event->getObjectData() ); @@ -106,8 +104,7 @@ class CalendarObjectReminderUpdaterListener implements IEventListener { } } elseif ($event instanceof CalendarObjectDeletedEvent) { try { - $this->reminderService->onTouchCalendarObject( - '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', + $this->reminderService->onCalendarObjectDelete( $event->getObjectData() ); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php index 2d4cbfd0c8..ce5b5acdd6 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php @@ -211,17 +211,15 @@ EOD; ->method('cleanRemindersForEvent') ->with(44); - $action = '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'; $objectData = [ 'id' => '44', 'component' => 'vevent', ]; - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectDelete($objectData); } public function testOnCalendarObjectCreateSingleEntry():void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA, 'id' => '42', @@ -242,11 +240,10 @@ EOD; ->with() ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-08T00:00:00+00:00')); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testOnCalendarObjectCreateSingleEntryWithRepeat(): void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA_REPEAT, 'id' => '42', @@ -270,11 +267,10 @@ EOD; ->with() ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-08T00:00:00+00:00')); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testOnCalendarObjectCreateRecurringEntry(): void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA_RECURRING, 'id' => '42', @@ -295,11 +291,10 @@ EOD; ->with() ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-29T00:00:00+00:00')); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testOnCalendarObjectCreateEmpty():void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA_NO_ALARM, 'id' => '42', @@ -310,11 +305,10 @@ EOD; $this->backend->expects($this->never()) ->method('insertReminder'); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testOnCalendarObjectCreateRecurringEntryWithRepeat():void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA_RECURRING_REPEAT, 'id' => '42', @@ -339,7 +333,7 @@ EOD; ->with() ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-29T00:00:00+00:00')); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testProcessReminders():void {