aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-05-07 11:43:31 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-05-07 12:13:47 +0200
commitf5462650f1480bf23a58285e0e4476957a0720db (patch)
treef37e180d90b1bbf3d92b175f13d25534191503ff /apps/dav/lib
parent257613e6efd429dd1c6cde4abbcbb590d32408e8 (diff)
downloadnextcloud-server-f5462650f1480bf23a58285e0e4476957a0720db.tar.gz
nextcloud-server-f5462650f1480bf23a58285e0e4476957a0720db.zip
Clean up reminder actions and call methods directly
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php2
-rw-r--r--apps/dav/lib/CalDAV/Reminder/ReminderService.php38
-rw-r--r--apps/dav/lib/Listener/CalendarObjectReminderUpdaterListener.php9
3 files changed, 15 insertions, 34 deletions
diff --git a/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php b/apps/dav/lib/BackgroundJob/BuildReminderIndexBackgroundJob.php
index ad5bf7736ab..badfc2ca041 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 9c27231cb8a..83fe413c0ee 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 4c201a19c3a..b976ef3ad9d 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()
);