Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2022-05-12 10:23:26 +0300
committerThomas Citharel <tcit@tcit.fr>2022-06-14 15:40:24 +0300
commit39ef0500d1d9b2d16540c7548100181e535f2a31 (patch)
tree0eb154048c90c8d9294da9aff4ec9a623c041d38 /apps/dav/lib/CalDAV/CalDavBackend.php
parentad10cd5f65fc145889bade0a57a910502cd02750 (diff)
Handle the move operation properly between shared calendars
- Introduce a new CalendarObjectMovedEvent typed event dedicated for this operation - Handle the event in the activity backend and add new appropriate activity subjects Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps/dav/lib/CalDAV/CalDavBackend.php')
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index f445382ce8c..3ab047d5183 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -52,6 +52,7 @@ use OCA\DAV\Events\CalendarDeletedEvent;
use OCA\DAV\Events\CalendarMovedToTrashEvent;
use OCA\DAV\Events\CalendarObjectCreatedEvent;
use OCA\DAV\Events\CalendarObjectDeletedEvent;
+use OCA\DAV\Events\CalendarObjectMovedEvent;
use OCA\DAV\Events\CalendarObjectMovedToTrashEvent;
use OCA\DAV\Events\CalendarObjectRestoredEvent;
use OCA\DAV\Events\CalendarObjectUpdatedEvent;
@@ -1341,13 +1342,14 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
* @param int $sourceCalendarId
* @param int $targetCalendarId
* @param int $objectId
- * @param string $principalUri
+ * @param string $oldPrincipalUri
+ * @param string $newPrincipalUri
* @param int $calendarType
* @return bool
* @throws Exception
*/
- public function moveCalendarObject(int $sourceCalendarId, int $targetCalendarId, int $objectId, string $principalUri, int $calendarType = self::CALENDAR_TYPE_CALENDAR): bool {
- $object = $this->getCalendarObjectById($principalUri, $objectId);
+ public function moveCalendarObject(int $sourceCalendarId, int $targetCalendarId, int $objectId, string $oldPrincipalUri, string $newPrincipalUri, int $calendarType = self::CALENDAR_TYPE_CALENDAR): bool {
+ $object = $this->getCalendarObjectById($oldPrincipalUri, $objectId);
if (empty($object)) {
return false;
}
@@ -1365,21 +1367,23 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$this->addChange($sourceCalendarId, $object['uri'], 1, $calendarType);
$this->addChange($targetCalendarId, $object['uri'], 3, $calendarType);
- $object = $this->getCalendarObjectById($principalUri, $objectId);
+ $object = $this->getCalendarObjectById($newPrincipalUri, $objectId);
// Calendar Object wasn't found - possibly because it was deleted in the meantime by a different client
if (empty($object)) {
return false;
}
- $calendarRow = $this->getCalendarById($targetCalendarId);
+ $targetCalendarRow = $this->getCalendarById($targetCalendarId);
// the calendar this event is being moved to does not exist any longer
- if (empty($calendarRow)) {
+ if (empty($targetCalendarRow)) {
return false;
}
if ($calendarType === self::CALENDAR_TYPE_CALENDAR) {
- $shares = $this->getShares($targetCalendarId);
- $this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent($targetCalendarId, $calendarRow, $shares, $object));
+ $sourceShares = $this->getShares($sourceCalendarId);
+ $targetShares = $this->getShares($targetCalendarId);
+ $sourceCalendarRow = $this->getCalendarById($sourceCalendarId);
+ $this->dispatcher->dispatchTyped(new CalendarObjectMovedEvent($sourceCalendarId, $sourceCalendarRow, $targetCalendarId, $targetCalendarRow, $sourceShares, $targetShares, $object));
}
return true;
}