Remove the \OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject event
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
d512a5629e
commit
f808267949
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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']);
|
||||
|
|
Loading…
Reference in New Issue