diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2016-11-14 16:13:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-14 16:13:16 +0100 |
commit | 04f8521b2c70abd22e617224ff7a0119e31183c7 (patch) | |
tree | 7fac326d69234382a9b1f9b7f08735c80c24330e /apps/dav/lib | |
parent | ff96fffe39c09efa60233988637d2fd68828a2ea (diff) | |
parent | 506ccdbd8dd7a9438fa69fe09bc9307ca5f346e3 (diff) | |
download | nextcloud-server-04f8521b2c70abd22e617224ff7a0119e31183c7.tar.gz nextcloud-server-04f8521b2c70abd22e617224ff7a0119e31183c7.zip |
Merge pull request #2112 from nextcloud/downstream-26206
Introduce an event for first time login based on the last login time …
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/AppInfo/Application.php | 12 | ||||
-rw-r--r-- | apps/dav/lib/HookManager.php | 7 |
2 files changed, 12 insertions, 7 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index c777f5e5a35..844e0780ffb 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -33,6 +33,7 @@ use OCA\DAV\CardDAV\SyncService; use OCA\DAV\HookManager; use \OCP\AppFramework\App; use OCP\Contacts\IManager; +use OCP\IUser; use Symfony\Component\EventDispatcher\GenericEvent; class Application extends App { @@ -65,6 +66,16 @@ class Application extends App { $hm = $this->getContainer()->query(HookManager::class); $hm->setup(); + $dispatcher = $this->getContainer()->getServer()->getEventDispatcher(); + + // first time login event setup + $dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm) { + if ($event instanceof GenericEvent) { + $hm->firstLogin($event->getSubject()); + } + }); + + // carddav/caldav sync event setup $listener = function($event) { if ($event instanceof GenericEvent) { /** @var BirthdayService $b */ @@ -77,7 +88,6 @@ class Application extends App { } }; - $dispatcher = $this->getContainer()->getServer()->getEventDispatcher(); $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) { diff --git a/apps/dav/lib/HookManager.php b/apps/dav/lib/HookManager.php index 92aa4fce7fa..247d4b291af 100644 --- a/apps/dav/lib/HookManager.php +++ b/apps/dav/lib/HookManager.php @@ -78,10 +78,6 @@ class HookManager { 'changeUser', $this, 'changeUser'); - Util::connectHook('OC_User', - 'post_login', - $this, - 'postLogin'); } public function postCreateUser($params) { @@ -117,8 +113,7 @@ class HookManager { $this->syncService->updateUser($user); } - public function postLogin($params) { - $user = $this->userManager->get($params['uid']); + public function firstLogin(IUser $user = null) { if (!is_null($user)) { $principal = 'principals/users/' . $user->getUID(); if ($this->calDav->getCalendarsForUserCount($principal) === 0) { |