summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/AppInfo
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2019-03-16 16:19:25 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-08-15 20:02:56 +0200
commit7bddcc091d5fe0f5e01325e16524d44fe8c1fb74 (patch)
tree6af37e4e745f5816292a2c496d34b12afe95440e /apps/dav/lib/AppInfo
parentf452e23a7db1742afa50eaa80b746afe769bdf7b (diff)
downloadnextcloud-server-7bddcc091d5fe0f5e01325e16524d44fe8c1fb74.tar.gz
nextcloud-server-7bddcc091d5fe0f5e01325e16524d44fe8c1fb74.zip
Support event reminders (email and notifications)
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps/dav/lib/AppInfo')
-rw-r--r--apps/dav/lib/AppInfo/Application.php58
1 files changed, 53 insertions, 5 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php
index 41570ee7442..2e3b95d8bfa 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -30,6 +30,12 @@ use OCA\DAV\CalDAV\Activity\Backend;
use OCA\DAV\CalDAV\Activity\Provider\Event;
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\CalendarManager;
+use OCA\DAV\CalDAV\Reminder\Backend as ReminderBackend;
+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\Capabilities;
use OCA\DAV\CardDAV\ContactsManager;
use OCA\DAV\CardDAV\PhotoCache;
@@ -43,6 +49,8 @@ use Symfony\Component\EventDispatcher\GenericEvent;
class Application extends App {
+ const APP_ID = 'dav';
+
/**
* Application constructor.
*/
@@ -109,8 +117,7 @@ class Application extends App {
}
});
- // carddav/caldav sync event setup
- $listener = function($event) {
+ $birthdayListener = function ($event) {
if ($event instanceof GenericEvent) {
/** @var BirthdayService $b */
$b = $this->getContainer()->query(BirthdayService::class);
@@ -122,9 +129,9 @@ class Application extends App {
}
};
- $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::createCard', $listener);
- $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $listener);
- $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', function($event) {
+ $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::createCard', $birthdayListener);
+ $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $birthdayListener);
+ $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', function ($event) {
if ($event instanceof GenericEvent) {
/** @var BirthdayService $b */
$b = $this->getContainer()->query(BirthdayService::class);
@@ -177,6 +184,11 @@ class Application extends App {
$event->getArgument('calendarData'),
$event->getArgument('shares')
);
+
+ $reminderBackend = $this->getContainer()->query(ReminderBackend::class);
+ $reminderBackend->cleanRemindersForCalendar(
+ $event->getArgument('calendarId')
+ );
});
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function(GenericEvent $event) {
/** @var Backend $backend */
@@ -187,6 +199,8 @@ class Application extends App {
$event->getArgument('add'),
$event->getArgument('remove')
);
+
+ // Here we should recalculate if reminders should be sent to new or old sharees
});
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', function(GenericEvent $event) {
@@ -214,6 +228,16 @@ class Application extends App {
$event->getArgument('shares'),
$event->getArgument('objectData')
);
+
+ /** @var ReminderService $reminderBackend */
+ $reminderService= $this->getContainer()->query(ReminderService::class);
+
+ $reminderService->onTouchCalendarObject(
+ $eventName,
+ $event->getArgument('calendarData'),
+ $event->getArgument('shares'),
+ $event->getArgument('objectData')
+ );
};
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener);
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener);
@@ -224,4 +248,28 @@ class Application extends App {
return $this->getContainer()->query(SyncService::class);
}
+ public function registerNotifier() {
+ $this->getContainer()->getServer()->getNotificationManager()->registerNotifier(function() {
+ return $this->getContainer()->query(Notifier::class);
+ }, function() {
+ $l = $this->getContainer()->getServer()->getL10NFactory()->get(self::APP_ID);
+ return [
+ 'id' => self::APP_ID,
+ 'name' => $l->t('Calendars and Contacts'),
+ ];
+ });
+ }
+
+ public function registerCalendarReminders(): void
+ {
+ try {
+ /** @var NotificationProviderManager $notificationProviderManager */
+ $notificationProviderManager = $this->getContainer()->query(NotificationProviderManager::class);
+ $notificationProviderManager->registerProvider(EmailProvider::class);
+ $notificationProviderManager->registerProvider(PushProvider::class);
+ } catch(\Exception $ex) {
+ $this->getContainer()->getServer()->getLogger()->logException($ex);
+ }
+ }
+
}