From dd181f4b2ad98fd75a6f1e90651d40363eb0f17c Mon Sep 17 00:00:00 2001 From: Edward Ly Date: Thu, 27 Feb 2025 17:20:12 -0800 Subject: feat(dav): add webhook compatibility for calendar object events Signed-off-by: Edward Ly --- apps/dav/lib/CalDAV/CalDavBackend.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'apps') diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 0c8b52a7491..32a6427052d 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -34,6 +34,12 @@ use OCA\DAV\Events\SubscriptionCreatedEvent; use OCA\DAV\Events\SubscriptionDeletedEvent; use OCA\DAV\Events\SubscriptionUpdatedEvent; use OCP\AppFramework\Db\TTransactional; +use OCP\Calendar\Events\CalendarObjectCreatedEvent as PublicCalendarObjectCreatedEvent; +use OCP\Calendar\Events\CalendarObjectDeletedEvent as PublicCalendarObjectDeletedEvent; +use OCP\Calendar\Events\CalendarObjectMovedEvent as PublicCalendarObjectMovedEvent; +use OCP\Calendar\Events\CalendarObjectMovedToTrashEvent as PublicCalendarObjectMovedToTrashEvent; +use OCP\Calendar\Events\CalendarObjectRestoredEvent as PublicCalendarObjectRestoredEvent; +use OCP\Calendar\Events\CalendarObjectUpdatedEvent as PublicCalendarObjectUpdatedEvent; use OCP\Calendar\Exceptions\CalendarException; use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -1318,6 +1324,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $shares = $this->getShares($calendarId); $this->dispatcher->dispatchTyped(new CalendarObjectCreatedEvent($calendarId, $calendarRow, $shares, $objectRow)); + $this->dispatcher->dispatchTyped(new PublicCalendarObjectCreatedEvent($calendarId, $calendarRow, $shares, $objectRow)); } else { $subscriptionRow = $this->getSubscriptionById($calendarId); @@ -1378,6 +1385,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $shares = $this->getShares($calendarId); $this->dispatcher->dispatchTyped(new CalendarObjectUpdatedEvent($calendarId, $calendarRow, $shares, $objectRow)); + $this->dispatcher->dispatchTyped(new PublicCalendarObjectUpdatedEvent($calendarId, $calendarRow, $shares, $objectRow)); } else { $subscriptionRow = $this->getSubscriptionById($calendarId); @@ -1439,6 +1447,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $targetShares = $this->getShares($targetCalendarId); $sourceCalendarRow = $this->getCalendarById($sourceCalendarId); $this->dispatcher->dispatchTyped(new CalendarObjectMovedEvent($sourceCalendarId, $sourceCalendarRow, $targetCalendarId, $targetCalendarRow, $sourceShares, $targetShares, $object)); + $this->dispatcher->dispatchTyped(new PublicCalendarObjectMovedEvent($sourceCalendarId, $sourceCalendarRow, $targetCalendarId, $targetCalendarRow, $sourceShares, $targetShares, $object)); } return true; }, $this->db); @@ -1497,6 +1506,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $shares = $this->getShares($calendarId); $this->dispatcher->dispatchTyped(new CalendarObjectDeletedEvent($calendarId, $calendarRow, $shares, $data)); + $this->dispatcher->dispatchTyped(new PublicCalendarObjectDeletedEvent($calendarId, $calendarRow, $shares, $data)); } else { $subscriptionRow = $this->getSubscriptionById($calendarId); @@ -1546,6 +1556,14 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $data ) ); + $this->dispatcher->dispatchTyped( + new PublicCalendarObjectMovedToTrashEvent( + $calendarId, + $calendarData, + $this->getShares($calendarId), + $data + ) + ); } } @@ -1605,6 +1623,14 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $row ) ); + $this->dispatcher->dispatchTyped( + new PublicCalendarObjectRestoredEvent( + (int)$objectData['calendarid'], + $calendarRow, + $this->getShares((int)$row['calendarid']), + $row + ) + ); }, $this->db); } -- cgit v1.2.3