@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInitContactsInteraction::getLoader(); |
@@ -6,14 +6,14 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\ContactsInteraction\\AddressBook' => $baseDir . '/../lib/AddressBook.php', |
|
| 10 | - 'OCA\\ContactsInteraction\\AddressBookProvider' => $baseDir . '/../lib/AddressBookProvider.php', |
|
| 11 | - 'OCA\\ContactsInteraction\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
| 12 | - 'OCA\\ContactsInteraction\\BackgroundJob\\CleanupJob' => $baseDir . '/../lib/BackgroundJob/CleanupJob.php', |
|
| 13 | - 'OCA\\ContactsInteraction\\Card' => $baseDir . '/../lib/Card.php', |
|
| 14 | - 'OCA\\ContactsInteraction\\Db\\CardSearchDao' => $baseDir . '/../lib/Db/CardSearchDao.php', |
|
| 15 | - 'OCA\\ContactsInteraction\\Db\\RecentContact' => $baseDir . '/../lib/Db/RecentContact.php', |
|
| 16 | - 'OCA\\ContactsInteraction\\Db\\RecentContactMapper' => $baseDir . '/../lib/Db/RecentContactMapper.php', |
|
| 17 | - 'OCA\\ContactsInteraction\\Listeners\\ContactInteractionListener' => $baseDir . '/../lib/Listeners/ContactInteractionListener.php', |
|
| 18 | - 'OCA\\ContactsInteraction\\Migration\\Version010000Date20200304152605' => $baseDir . '/../lib/Migration/Version010000Date20200304152605.php', |
|
| 9 | + 'OCA\\ContactsInteraction\\AddressBook' => $baseDir.'/../lib/AddressBook.php', |
|
| 10 | + 'OCA\\ContactsInteraction\\AddressBookProvider' => $baseDir.'/../lib/AddressBookProvider.php', |
|
| 11 | + 'OCA\\ContactsInteraction\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
| 12 | + 'OCA\\ContactsInteraction\\BackgroundJob\\CleanupJob' => $baseDir.'/../lib/BackgroundJob/CleanupJob.php', |
|
| 13 | + 'OCA\\ContactsInteraction\\Card' => $baseDir.'/../lib/Card.php', |
|
| 14 | + 'OCA\\ContactsInteraction\\Db\\CardSearchDao' => $baseDir.'/../lib/Db/CardSearchDao.php', |
|
| 15 | + 'OCA\\ContactsInteraction\\Db\\RecentContact' => $baseDir.'/../lib/Db/RecentContact.php', |
|
| 16 | + 'OCA\\ContactsInteraction\\Db\\RecentContactMapper' => $baseDir.'/../lib/Db/RecentContactMapper.php', |
|
| 17 | + 'OCA\\ContactsInteraction\\Listeners\\ContactInteractionListener' => $baseDir.'/../lib/Listeners/ContactInteractionListener.php', |
|
| 18 | + 'OCA\\ContactsInteraction\\Migration\\Version010000Date20200304152605' => $baseDir.'/../lib/Migration/Version010000Date20200304152605.php', |
|
| 19 | 19 | ); |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'OCA\\ContactsInteraction\\' => array($baseDir . '/../lib'), |
|
| 9 | + 'OCA\\ContactsInteraction\\' => array($baseDir.'/../lib'), |
|
| 10 | 10 | ); |
@@ -370,18 +370,18 @@ discard block |
||
| 370 | 370 | private function findFileWithExtension($class, $ext) |
| 371 | 371 | { |
| 372 | 372 | // PSR-4 lookup |
| 373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 374 | 374 | |
| 375 | 375 | $first = $class[0]; |
| 376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 377 | 377 | $subPath = $class; |
| 378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
| 380 | - $search = $subPath . '\\'; |
|
| 380 | + $search = $subPath.'\\'; |
|
| 381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
| 382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 385 | 385 | return $file; |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | // PSR-4 fallback dirs |
| 393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 395 | 395 | return $file; |
| 396 | 396 | } |
| 397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 404 | 404 | } else { |
| 405 | 405 | // PEAR-like class name |
| 406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
| 410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 411 | 411 | if (0 === strpos($class, $prefix)) { |
| 412 | 412 | foreach ($dirs as $dir) { |
| 413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 414 | 414 | return $file; |
| 415 | 415 | } |
| 416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | // PSR-0 fallback dirs |
| 422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 424 | 424 | return $file; |
| 425 | 425 | } |
| 426 | 426 | } |
@@ -6,36 +6,36 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInitContactsInteraction |
| 8 | 8 | { |
| 9 | - public static $prefixLengthsPsr4 = array ( |
|
| 9 | + public static $prefixLengthsPsr4 = array( |
|
| 10 | 10 | 'O' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'OCA\\ContactsInteraction\\' => 24, |
| 13 | 13 | ), |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( |
|
| 16 | + public static $prefixDirsPsr4 = array( |
|
| 17 | 17 | 'OCA\\ContactsInteraction\\' => |
| 18 | - array ( |
|
| 19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
| 18 | + array( |
|
| 19 | + 0 => __DIR__.'/..'.'/../lib', |
|
| 20 | 20 | ), |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public static $classMap = array ( |
|
| 24 | - 'OCA\\ContactsInteraction\\AddressBook' => __DIR__ . '/..' . '/../lib/AddressBook.php', |
|
| 25 | - 'OCA\\ContactsInteraction\\AddressBookProvider' => __DIR__ . '/..' . '/../lib/AddressBookProvider.php', |
|
| 26 | - 'OCA\\ContactsInteraction\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
| 27 | - 'OCA\\ContactsInteraction\\BackgroundJob\\CleanupJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupJob.php', |
|
| 28 | - 'OCA\\ContactsInteraction\\Card' => __DIR__ . '/..' . '/../lib/Card.php', |
|
| 29 | - 'OCA\\ContactsInteraction\\Db\\CardSearchDao' => __DIR__ . '/..' . '/../lib/Db/CardSearchDao.php', |
|
| 30 | - 'OCA\\ContactsInteraction\\Db\\RecentContact' => __DIR__ . '/..' . '/../lib/Db/RecentContact.php', |
|
| 31 | - 'OCA\\ContactsInteraction\\Db\\RecentContactMapper' => __DIR__ . '/..' . '/../lib/Db/RecentContactMapper.php', |
|
| 32 | - 'OCA\\ContactsInteraction\\Listeners\\ContactInteractionListener' => __DIR__ . '/..' . '/../lib/Listeners/ContactInteractionListener.php', |
|
| 33 | - 'OCA\\ContactsInteraction\\Migration\\Version010000Date20200304152605' => __DIR__ . '/..' . '/../lib/Migration/Version010000Date20200304152605.php', |
|
| 23 | + public static $classMap = array( |
|
| 24 | + 'OCA\\ContactsInteraction\\AddressBook' => __DIR__.'/..'.'/../lib/AddressBook.php', |
|
| 25 | + 'OCA\\ContactsInteraction\\AddressBookProvider' => __DIR__.'/..'.'/../lib/AddressBookProvider.php', |
|
| 26 | + 'OCA\\ContactsInteraction\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
| 27 | + 'OCA\\ContactsInteraction\\BackgroundJob\\CleanupJob' => __DIR__.'/..'.'/../lib/BackgroundJob/CleanupJob.php', |
|
| 28 | + 'OCA\\ContactsInteraction\\Card' => __DIR__.'/..'.'/../lib/Card.php', |
|
| 29 | + 'OCA\\ContactsInteraction\\Db\\CardSearchDao' => __DIR__.'/..'.'/../lib/Db/CardSearchDao.php', |
|
| 30 | + 'OCA\\ContactsInteraction\\Db\\RecentContact' => __DIR__.'/..'.'/../lib/Db/RecentContact.php', |
|
| 31 | + 'OCA\\ContactsInteraction\\Db\\RecentContactMapper' => __DIR__.'/..'.'/../lib/Db/RecentContactMapper.php', |
|
| 32 | + 'OCA\\ContactsInteraction\\Listeners\\ContactInteractionListener' => __DIR__.'/..'.'/../lib/Listeners/ContactInteractionListener.php', |
|
| 33 | + 'OCA\\ContactsInteraction\\Migration\\Version010000Date20200304152605' => __DIR__.'/..'.'/../lib/Migration/Version010000Date20200304152605.php', |
|
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | 36 | public static function getInitializer(ClassLoader $loader) |
| 37 | 37 | { |
| 38 | - return \Closure::bind(function () use ($loader) { |
|
| 38 | + return \Closure::bind(function() use ($loader) { |
|
| 39 | 39 | $loader->prefixLengthsPsr4 = ComposerStaticInitContactsInteraction::$prefixLengthsPsr4; |
| 40 | 40 | $loader->prefixDirsPsr4 = ComposerStaticInitContactsInteraction::$prefixDirsPsr4; |
| 41 | 41 | $loader->classMap = ComposerStaticInitContactsInteraction::$classMap; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | public static function loadClassLoader($class) |
| 10 | 10 | { |
| 11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
| 12 | - require __DIR__ . '/ClassLoader.php'; |
|
| 12 | + require __DIR__.'/ClassLoader.php'; |
|
| 13 | 13 | } |
| 14 | 14 | } |
| 15 | 15 | |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
| 30 | 30 | if ($useStaticLoader) { |
| 31 | - require_once __DIR__ . '/autoload_static.php'; |
|
| 31 | + require_once __DIR__.'/autoload_static.php'; |
|
| 32 | 32 | |
| 33 | 33 | call_user_func(\Composer\Autoload\ComposerStaticInitContactsInteraction::getInitializer($loader)); |
| 34 | 34 | } else { |
| 35 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
| 35 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
| 36 | 36 | if ($classMap) { |
| 37 | 37 | $loader->addClassMap($classMap); |
| 38 | 38 | } |
@@ -40,84 +40,84 @@ |
||
| 40 | 40 | |
| 41 | 41 | class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome { |
| 42 | 42 | |
| 43 | - /** @var IL10N */ |
|
| 44 | - protected $l10n; |
|
| 45 | - |
|
| 46 | - /** @var IConfig */ |
|
| 47 | - protected $config; |
|
| 48 | - |
|
| 49 | - /** @var PluginManager */ |
|
| 50 | - private $pluginManager; |
|
| 51 | - |
|
| 52 | - public function __construct(Backend\BackendInterface $carddavBackend, |
|
| 53 | - string $principalUri, |
|
| 54 | - PluginManager $pluginManager) { |
|
| 55 | - parent::__construct($carddavBackend, $principalUri); |
|
| 56 | - $this->pluginManager = $pluginManager; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Returns a list of address books |
|
| 61 | - * |
|
| 62 | - * @return IAddressBook[] |
|
| 63 | - */ |
|
| 64 | - function getChildren() { |
|
| 65 | - if ($this->l10n === null) { |
|
| 66 | - $this->l10n = \OC::$server->getL10N('dav'); |
|
| 67 | - } |
|
| 68 | - if ($this->config === null) { |
|
| 69 | - $this->config = \OC::$server->getConfig(); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $addressBooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri); |
|
| 73 | - /** @var IAddressBook[] $objects */ |
|
| 74 | - $objects = array_map(function(array $addressBook) { |
|
| 75 | - if ($addressBook['principaluri'] === 'principals/system/system') { |
|
| 76 | - return new SystemAddressbook($this->carddavBackend, $addressBook, $this->l10n, $this->config); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - return new AddressBook($this->carddavBackend, $addressBook, $this->l10n); |
|
| 80 | - }, $addressBooks); |
|
| 81 | - /** @var IAddressBook[][] $objectsFromPlugins */ |
|
| 82 | - $objectsFromPlugins = array_map(function(IAddressBookProvider $plugin): array { |
|
| 83 | - return $plugin->fetchAllForAddressBookHome($this->principalUri); |
|
| 84 | - }, $this->pluginManager->getAddressBookPlugins()); |
|
| 85 | - |
|
| 86 | - return array_merge($objects, ...$objectsFromPlugins); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - public function createExtendedCollection($name, MkCol $mkCol) { |
|
| 90 | - if (ExternalAddressBook::doesViolateReservedName($name)) { |
|
| 91 | - throw new MethodNotAllowed('The resource you tried to create has a reserved name'); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - parent::createExtendedCollection($name, $mkCol); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Returns a list of ACE's for this node. |
|
| 99 | - * |
|
| 100 | - * Each ACE has the following properties: |
|
| 101 | - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
| 102 | - * currently the only supported privileges |
|
| 103 | - * * 'principal', a url to the principal who owns the node |
|
| 104 | - * * 'protected' (optional), indicating that this ACE is not allowed to |
|
| 105 | - * be updated. |
|
| 106 | - * |
|
| 107 | - * @return array |
|
| 108 | - */ |
|
| 109 | - function getACL() { |
|
| 110 | - |
|
| 111 | - $acl = parent::getACL(); |
|
| 112 | - if ($this->principalUri === 'principals/system/system') { |
|
| 113 | - $acl[] = [ |
|
| 114 | - 'privilege' => '{DAV:}read', |
|
| 115 | - 'principal' => '{DAV:}authenticated', |
|
| 116 | - 'protected' => true, |
|
| 117 | - ]; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - return $acl; |
|
| 121 | - } |
|
| 43 | + /** @var IL10N */ |
|
| 44 | + protected $l10n; |
|
| 45 | + |
|
| 46 | + /** @var IConfig */ |
|
| 47 | + protected $config; |
|
| 48 | + |
|
| 49 | + /** @var PluginManager */ |
|
| 50 | + private $pluginManager; |
|
| 51 | + |
|
| 52 | + public function __construct(Backend\BackendInterface $carddavBackend, |
|
| 53 | + string $principalUri, |
|
| 54 | + PluginManager $pluginManager) { |
|
| 55 | + parent::__construct($carddavBackend, $principalUri); |
|
| 56 | + $this->pluginManager = $pluginManager; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Returns a list of address books |
|
| 61 | + * |
|
| 62 | + * @return IAddressBook[] |
|
| 63 | + */ |
|
| 64 | + function getChildren() { |
|
| 65 | + if ($this->l10n === null) { |
|
| 66 | + $this->l10n = \OC::$server->getL10N('dav'); |
|
| 67 | + } |
|
| 68 | + if ($this->config === null) { |
|
| 69 | + $this->config = \OC::$server->getConfig(); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $addressBooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri); |
|
| 73 | + /** @var IAddressBook[] $objects */ |
|
| 74 | + $objects = array_map(function(array $addressBook) { |
|
| 75 | + if ($addressBook['principaluri'] === 'principals/system/system') { |
|
| 76 | + return new SystemAddressbook($this->carddavBackend, $addressBook, $this->l10n, $this->config); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + return new AddressBook($this->carddavBackend, $addressBook, $this->l10n); |
|
| 80 | + }, $addressBooks); |
|
| 81 | + /** @var IAddressBook[][] $objectsFromPlugins */ |
|
| 82 | + $objectsFromPlugins = array_map(function(IAddressBookProvider $plugin): array { |
|
| 83 | + return $plugin->fetchAllForAddressBookHome($this->principalUri); |
|
| 84 | + }, $this->pluginManager->getAddressBookPlugins()); |
|
| 85 | + |
|
| 86 | + return array_merge($objects, ...$objectsFromPlugins); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + public function createExtendedCollection($name, MkCol $mkCol) { |
|
| 90 | + if (ExternalAddressBook::doesViolateReservedName($name)) { |
|
| 91 | + throw new MethodNotAllowed('The resource you tried to create has a reserved name'); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + parent::createExtendedCollection($name, $mkCol); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Returns a list of ACE's for this node. |
|
| 99 | + * |
|
| 100 | + * Each ACE has the following properties: |
|
| 101 | + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
| 102 | + * currently the only supported privileges |
|
| 103 | + * * 'principal', a url to the principal who owns the node |
|
| 104 | + * * 'protected' (optional), indicating that this ACE is not allowed to |
|
| 105 | + * be updated. |
|
| 106 | + * |
|
| 107 | + * @return array |
|
| 108 | + */ |
|
| 109 | + function getACL() { |
|
| 110 | + |
|
| 111 | + $acl = parent::getACL(); |
|
| 112 | + if ($this->principalUri === 'principals/system/system') { |
|
| 113 | + $acl[] = [ |
|
| 114 | + 'privilege' => '{DAV:}read', |
|
| 115 | + 'principal' => '{DAV:}authenticated', |
|
| 116 | + 'protected' => true, |
|
| 117 | + ]; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + return $acl; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | } |
@@ -65,242 +65,242 @@ |
||
| 65 | 65 | |
| 66 | 66 | class Application extends App { |
| 67 | 67 | |
| 68 | - const APP_ID = 'files_sharing'; |
|
| 69 | - |
|
| 70 | - public function __construct(array $urlParams = []) { |
|
| 71 | - parent::__construct(self::APP_ID, $urlParams); |
|
| 72 | - |
|
| 73 | - $container = $this->getContainer(); |
|
| 74 | - |
|
| 75 | - /** @var IServerContainer $server */ |
|
| 76 | - $server = $container->getServer(); |
|
| 77 | - |
|
| 78 | - /** @var IEventDispatcher $dispatcher */ |
|
| 79 | - $dispatcher = $container->query(IEventDispatcher::class); |
|
| 80 | - $mountProviderCollection = $server->getMountProviderCollection(); |
|
| 81 | - $notifications = $server->getNotificationManager(); |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Controllers |
|
| 85 | - */ |
|
| 86 | - $container->registerService('ShareController', function (SimpleContainer $c) use ($server) { |
|
| 87 | - $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
| 88 | - return new ShareController( |
|
| 89 | - $c->query('AppName'), |
|
| 90 | - $c->query('Request'), |
|
| 91 | - $server->getConfig(), |
|
| 92 | - $server->getURLGenerator(), |
|
| 93 | - $server->getUserManager(), |
|
| 94 | - $server->getLogger(), |
|
| 95 | - $server->getActivityManager(), |
|
| 96 | - $server->getShareManager(), |
|
| 97 | - $server->getSession(), |
|
| 98 | - $server->getPreviewManager(), |
|
| 99 | - $server->getRootFolder(), |
|
| 100 | - $federatedSharingApp->getFederatedShareProvider(), |
|
| 101 | - $server->getEventDispatcher(), |
|
| 102 | - $server->getL10N($c->query('AppName')), |
|
| 103 | - $server->query(Defaults::class) |
|
| 104 | - ); |
|
| 105 | - }); |
|
| 106 | - $container->registerService('ExternalSharesController', function (SimpleContainer $c) { |
|
| 107 | - return new ExternalSharesController( |
|
| 108 | - $c->query('AppName'), |
|
| 109 | - $c->query('Request'), |
|
| 110 | - $c->query('ExternalManager'), |
|
| 111 | - $c->query('HttpClientService') |
|
| 112 | - ); |
|
| 113 | - }); |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Core class wrappers |
|
| 117 | - */ |
|
| 118 | - $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { |
|
| 119 | - return $server->getHTTPClientService(); |
|
| 120 | - }); |
|
| 121 | - $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { |
|
| 122 | - return $server->getCloudIdManager(); |
|
| 123 | - }); |
|
| 124 | - $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { |
|
| 125 | - $user = $server->getUserSession()->getUser(); |
|
| 126 | - $uid = $user ? $user->getUID() : null; |
|
| 127 | - return new \OCA\Files_Sharing\External\Manager( |
|
| 128 | - $server->getDatabaseConnection(), |
|
| 129 | - \OC\Files\Filesystem::getMountManager(), |
|
| 130 | - \OC\Files\Filesystem::getLoader(), |
|
| 131 | - $server->getHTTPClientService(), |
|
| 132 | - $server->getNotificationManager(), |
|
| 133 | - $server->query(\OCP\OCS\IDiscoveryService::class), |
|
| 134 | - $server->getCloudFederationProviderManager(), |
|
| 135 | - $server->getCloudFederationFactory(), |
|
| 136 | - $server->getGroupManager(), |
|
| 137 | - $server->getUserManager(), |
|
| 138 | - $uid |
|
| 139 | - ); |
|
| 140 | - }); |
|
| 141 | - $container->registerAlias(Manager::class, 'ExternalManager'); |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Middleware |
|
| 145 | - */ |
|
| 146 | - $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { |
|
| 147 | - return new SharingCheckMiddleware( |
|
| 148 | - $c->query('AppName'), |
|
| 149 | - $server->getConfig(), |
|
| 150 | - $server->getAppManager(), |
|
| 151 | - $server->query(IControllerMethodReflector::class), |
|
| 152 | - $server->getShareManager(), |
|
| 153 | - $server->getRequest() |
|
| 154 | - ); |
|
| 155 | - }); |
|
| 156 | - |
|
| 157 | - $container->registerService(ShareInfoMiddleware::class, function () use ($server) { |
|
| 158 | - return new ShareInfoMiddleware( |
|
| 159 | - $server->getShareManager() |
|
| 160 | - ); |
|
| 161 | - }); |
|
| 162 | - |
|
| 163 | - // Execute middlewares |
|
| 164 | - $container->registerMiddleWare('SharingCheckMiddleware'); |
|
| 165 | - $container->registerMiddleWare(OCSShareAPIMiddleware::class); |
|
| 166 | - $container->registerMiddleWare(ShareInfoMiddleware::class); |
|
| 167 | - |
|
| 168 | - $container->registerService('MountProvider', function (IContainer $c) { |
|
| 169 | - /** @var \OCP\IServerContainer $server */ |
|
| 170 | - $server = $c->query('ServerContainer'); |
|
| 171 | - return new MountProvider( |
|
| 172 | - $server->getConfig(), |
|
| 173 | - $server->getShareManager(), |
|
| 174 | - $server->getLogger() |
|
| 175 | - ); |
|
| 176 | - }); |
|
| 177 | - |
|
| 178 | - $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
| 179 | - /** @var \OCP\IServerContainer $server */ |
|
| 180 | - $server = $c->query('ServerContainer'); |
|
| 181 | - return new \OCA\Files_Sharing\External\MountProvider( |
|
| 182 | - $server->getDatabaseConnection(), |
|
| 183 | - function() use ($c) { |
|
| 184 | - return $c->query('ExternalManager'); |
|
| 185 | - }, |
|
| 186 | - $server->getCloudIdManager() |
|
| 187 | - ); |
|
| 188 | - }); |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Register capabilities |
|
| 192 | - */ |
|
| 193 | - $container->registerCapability(Capabilities::class); |
|
| 194 | - |
|
| 195 | - $notifications->registerNotifierService(Notifier::class); |
|
| 196 | - |
|
| 197 | - $this->registerMountProviders($mountProviderCollection); |
|
| 198 | - $this->registerEventsScripts($dispatcher); |
|
| 199 | - $this->setupSharingMenus(); |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Always add main sharing script |
|
| 203 | - */ |
|
| 204 | - Util::addScript(self::APP_ID, 'dist/main'); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) { |
|
| 208 | - $mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider')); |
|
| 209 | - $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - protected function registerEventsScripts(IEventDispatcher $dispatcher) { |
|
| 213 | - // sidebar and files scripts |
|
| 214 | - $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); |
|
| 215 | - $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); |
|
| 216 | - $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); |
|
| 217 | - $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function() { |
|
| 218 | - \OCP\Util::addScript('files_sharing', 'dist/collaboration'); |
|
| 219 | - }); |
|
| 220 | - $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); |
|
| 221 | - $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class); |
|
| 222 | - |
|
| 223 | - // notifications api to accept incoming user shares |
|
| 224 | - $dispatcher->addListener('OCP\Share::postShare', function(GenericEvent $event) { |
|
| 225 | - /** @var Listener $listener */ |
|
| 226 | - $listener = $this->getContainer()->query(Listener::class); |
|
| 227 | - $listener->shareNotification($event); |
|
| 228 | - }); |
|
| 229 | - $dispatcher->addListener(IGroup::class . '::postAddUser', function(GenericEvent $event) { |
|
| 230 | - /** @var Listener $listener */ |
|
| 231 | - $listener = $this->getContainer()->query(Listener::class); |
|
| 232 | - $listener->userAddedToGroup($event); |
|
| 233 | - }); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - protected function setupSharingMenus() { |
|
| 237 | - $config = \OC::$server->getConfig(); |
|
| 238 | - $l = \OC::$server->getL10N('files_sharing'); |
|
| 239 | - |
|
| 240 | - if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { |
|
| 241 | - return; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - $sharingSublistArray = []; |
|
| 245 | - |
|
| 246 | - if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
| 247 | - array_push($sharingSublistArray, [ |
|
| 248 | - 'id' => 'sharingout', |
|
| 249 | - 'appname' => 'files_sharing', |
|
| 250 | - 'script' => 'list.php', |
|
| 251 | - 'order' => 16, |
|
| 252 | - 'name' => $l->t('Shared with others'), |
|
| 253 | - ]); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - array_push($sharingSublistArray, [ |
|
| 257 | - 'id' => 'sharingin', |
|
| 258 | - 'appname' => 'files_sharing', |
|
| 259 | - 'script' => 'list.php', |
|
| 260 | - 'order' => 15, |
|
| 261 | - 'name' => $l->t('Shared with you'), |
|
| 262 | - ]); |
|
| 263 | - |
|
| 264 | - if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
| 265 | - // Check if sharing by link is enabled |
|
| 266 | - if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { |
|
| 267 | - array_push($sharingSublistArray, [ |
|
| 268 | - 'id' => 'sharinglinks', |
|
| 269 | - 'appname' => 'files_sharing', |
|
| 270 | - 'script' => 'list.php', |
|
| 271 | - 'order' => 17, |
|
| 272 | - 'name' => $l->t('Shared by link'), |
|
| 273 | - ]); |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - array_push($sharingSublistArray, [ |
|
| 278 | - 'id' => 'deletedshares', |
|
| 279 | - 'appname' => 'files_sharing', |
|
| 280 | - 'script' => 'list.php', |
|
| 281 | - 'order' => 19, |
|
| 282 | - 'name' => $l->t('Deleted shares'), |
|
| 283 | - ]); |
|
| 284 | - |
|
| 285 | - array_push($sharingSublistArray, [ |
|
| 286 | - 'id' => 'pendingshares', |
|
| 287 | - 'appname' => 'files_sharing', |
|
| 288 | - 'script' => 'list.php', |
|
| 289 | - 'order' => 19, |
|
| 290 | - 'name' => $l->t('Pending shares'), |
|
| 291 | - ]); |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - // show_Quick_Access stored as string |
|
| 295 | - \OCA\Files\App::getNavigationManager()->add([ |
|
| 296 | - 'id' => 'shareoverview', |
|
| 297 | - 'appname' => 'files_sharing', |
|
| 298 | - 'script' => 'list.php', |
|
| 299 | - 'order' => 18, |
|
| 300 | - 'name' => $l->t('Shares'), |
|
| 301 | - 'classes' => 'collapsible', |
|
| 302 | - 'sublist' => $sharingSublistArray, |
|
| 303 | - 'expandedState' => 'show_sharing_menu' |
|
| 304 | - ]); |
|
| 305 | - } |
|
| 68 | + const APP_ID = 'files_sharing'; |
|
| 69 | + |
|
| 70 | + public function __construct(array $urlParams = []) { |
|
| 71 | + parent::__construct(self::APP_ID, $urlParams); |
|
| 72 | + |
|
| 73 | + $container = $this->getContainer(); |
|
| 74 | + |
|
| 75 | + /** @var IServerContainer $server */ |
|
| 76 | + $server = $container->getServer(); |
|
| 77 | + |
|
| 78 | + /** @var IEventDispatcher $dispatcher */ |
|
| 79 | + $dispatcher = $container->query(IEventDispatcher::class); |
|
| 80 | + $mountProviderCollection = $server->getMountProviderCollection(); |
|
| 81 | + $notifications = $server->getNotificationManager(); |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Controllers |
|
| 85 | + */ |
|
| 86 | + $container->registerService('ShareController', function (SimpleContainer $c) use ($server) { |
|
| 87 | + $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
| 88 | + return new ShareController( |
|
| 89 | + $c->query('AppName'), |
|
| 90 | + $c->query('Request'), |
|
| 91 | + $server->getConfig(), |
|
| 92 | + $server->getURLGenerator(), |
|
| 93 | + $server->getUserManager(), |
|
| 94 | + $server->getLogger(), |
|
| 95 | + $server->getActivityManager(), |
|
| 96 | + $server->getShareManager(), |
|
| 97 | + $server->getSession(), |
|
| 98 | + $server->getPreviewManager(), |
|
| 99 | + $server->getRootFolder(), |
|
| 100 | + $federatedSharingApp->getFederatedShareProvider(), |
|
| 101 | + $server->getEventDispatcher(), |
|
| 102 | + $server->getL10N($c->query('AppName')), |
|
| 103 | + $server->query(Defaults::class) |
|
| 104 | + ); |
|
| 105 | + }); |
|
| 106 | + $container->registerService('ExternalSharesController', function (SimpleContainer $c) { |
|
| 107 | + return new ExternalSharesController( |
|
| 108 | + $c->query('AppName'), |
|
| 109 | + $c->query('Request'), |
|
| 110 | + $c->query('ExternalManager'), |
|
| 111 | + $c->query('HttpClientService') |
|
| 112 | + ); |
|
| 113 | + }); |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Core class wrappers |
|
| 117 | + */ |
|
| 118 | + $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { |
|
| 119 | + return $server->getHTTPClientService(); |
|
| 120 | + }); |
|
| 121 | + $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { |
|
| 122 | + return $server->getCloudIdManager(); |
|
| 123 | + }); |
|
| 124 | + $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { |
|
| 125 | + $user = $server->getUserSession()->getUser(); |
|
| 126 | + $uid = $user ? $user->getUID() : null; |
|
| 127 | + return new \OCA\Files_Sharing\External\Manager( |
|
| 128 | + $server->getDatabaseConnection(), |
|
| 129 | + \OC\Files\Filesystem::getMountManager(), |
|
| 130 | + \OC\Files\Filesystem::getLoader(), |
|
| 131 | + $server->getHTTPClientService(), |
|
| 132 | + $server->getNotificationManager(), |
|
| 133 | + $server->query(\OCP\OCS\IDiscoveryService::class), |
|
| 134 | + $server->getCloudFederationProviderManager(), |
|
| 135 | + $server->getCloudFederationFactory(), |
|
| 136 | + $server->getGroupManager(), |
|
| 137 | + $server->getUserManager(), |
|
| 138 | + $uid |
|
| 139 | + ); |
|
| 140 | + }); |
|
| 141 | + $container->registerAlias(Manager::class, 'ExternalManager'); |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Middleware |
|
| 145 | + */ |
|
| 146 | + $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { |
|
| 147 | + return new SharingCheckMiddleware( |
|
| 148 | + $c->query('AppName'), |
|
| 149 | + $server->getConfig(), |
|
| 150 | + $server->getAppManager(), |
|
| 151 | + $server->query(IControllerMethodReflector::class), |
|
| 152 | + $server->getShareManager(), |
|
| 153 | + $server->getRequest() |
|
| 154 | + ); |
|
| 155 | + }); |
|
| 156 | + |
|
| 157 | + $container->registerService(ShareInfoMiddleware::class, function () use ($server) { |
|
| 158 | + return new ShareInfoMiddleware( |
|
| 159 | + $server->getShareManager() |
|
| 160 | + ); |
|
| 161 | + }); |
|
| 162 | + |
|
| 163 | + // Execute middlewares |
|
| 164 | + $container->registerMiddleWare('SharingCheckMiddleware'); |
|
| 165 | + $container->registerMiddleWare(OCSShareAPIMiddleware::class); |
|
| 166 | + $container->registerMiddleWare(ShareInfoMiddleware::class); |
|
| 167 | + |
|
| 168 | + $container->registerService('MountProvider', function (IContainer $c) { |
|
| 169 | + /** @var \OCP\IServerContainer $server */ |
|
| 170 | + $server = $c->query('ServerContainer'); |
|
| 171 | + return new MountProvider( |
|
| 172 | + $server->getConfig(), |
|
| 173 | + $server->getShareManager(), |
|
| 174 | + $server->getLogger() |
|
| 175 | + ); |
|
| 176 | + }); |
|
| 177 | + |
|
| 178 | + $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
| 179 | + /** @var \OCP\IServerContainer $server */ |
|
| 180 | + $server = $c->query('ServerContainer'); |
|
| 181 | + return new \OCA\Files_Sharing\External\MountProvider( |
|
| 182 | + $server->getDatabaseConnection(), |
|
| 183 | + function() use ($c) { |
|
| 184 | + return $c->query('ExternalManager'); |
|
| 185 | + }, |
|
| 186 | + $server->getCloudIdManager() |
|
| 187 | + ); |
|
| 188 | + }); |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Register capabilities |
|
| 192 | + */ |
|
| 193 | + $container->registerCapability(Capabilities::class); |
|
| 194 | + |
|
| 195 | + $notifications->registerNotifierService(Notifier::class); |
|
| 196 | + |
|
| 197 | + $this->registerMountProviders($mountProviderCollection); |
|
| 198 | + $this->registerEventsScripts($dispatcher); |
|
| 199 | + $this->setupSharingMenus(); |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Always add main sharing script |
|
| 203 | + */ |
|
| 204 | + Util::addScript(self::APP_ID, 'dist/main'); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) { |
|
| 208 | + $mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider')); |
|
| 209 | + $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + protected function registerEventsScripts(IEventDispatcher $dispatcher) { |
|
| 213 | + // sidebar and files scripts |
|
| 214 | + $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); |
|
| 215 | + $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); |
|
| 216 | + $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); |
|
| 217 | + $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function() { |
|
| 218 | + \OCP\Util::addScript('files_sharing', 'dist/collaboration'); |
|
| 219 | + }); |
|
| 220 | + $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); |
|
| 221 | + $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class); |
|
| 222 | + |
|
| 223 | + // notifications api to accept incoming user shares |
|
| 224 | + $dispatcher->addListener('OCP\Share::postShare', function(GenericEvent $event) { |
|
| 225 | + /** @var Listener $listener */ |
|
| 226 | + $listener = $this->getContainer()->query(Listener::class); |
|
| 227 | + $listener->shareNotification($event); |
|
| 228 | + }); |
|
| 229 | + $dispatcher->addListener(IGroup::class . '::postAddUser', function(GenericEvent $event) { |
|
| 230 | + /** @var Listener $listener */ |
|
| 231 | + $listener = $this->getContainer()->query(Listener::class); |
|
| 232 | + $listener->userAddedToGroup($event); |
|
| 233 | + }); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + protected function setupSharingMenus() { |
|
| 237 | + $config = \OC::$server->getConfig(); |
|
| 238 | + $l = \OC::$server->getL10N('files_sharing'); |
|
| 239 | + |
|
| 240 | + if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { |
|
| 241 | + return; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + $sharingSublistArray = []; |
|
| 245 | + |
|
| 246 | + if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
| 247 | + array_push($sharingSublistArray, [ |
|
| 248 | + 'id' => 'sharingout', |
|
| 249 | + 'appname' => 'files_sharing', |
|
| 250 | + 'script' => 'list.php', |
|
| 251 | + 'order' => 16, |
|
| 252 | + 'name' => $l->t('Shared with others'), |
|
| 253 | + ]); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + array_push($sharingSublistArray, [ |
|
| 257 | + 'id' => 'sharingin', |
|
| 258 | + 'appname' => 'files_sharing', |
|
| 259 | + 'script' => 'list.php', |
|
| 260 | + 'order' => 15, |
|
| 261 | + 'name' => $l->t('Shared with you'), |
|
| 262 | + ]); |
|
| 263 | + |
|
| 264 | + if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
| 265 | + // Check if sharing by link is enabled |
|
| 266 | + if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { |
|
| 267 | + array_push($sharingSublistArray, [ |
|
| 268 | + 'id' => 'sharinglinks', |
|
| 269 | + 'appname' => 'files_sharing', |
|
| 270 | + 'script' => 'list.php', |
|
| 271 | + 'order' => 17, |
|
| 272 | + 'name' => $l->t('Shared by link'), |
|
| 273 | + ]); |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + array_push($sharingSublistArray, [ |
|
| 278 | + 'id' => 'deletedshares', |
|
| 279 | + 'appname' => 'files_sharing', |
|
| 280 | + 'script' => 'list.php', |
|
| 281 | + 'order' => 19, |
|
| 282 | + 'name' => $l->t('Deleted shares'), |
|
| 283 | + ]); |
|
| 284 | + |
|
| 285 | + array_push($sharingSublistArray, [ |
|
| 286 | + 'id' => 'pendingshares', |
|
| 287 | + 'appname' => 'files_sharing', |
|
| 288 | + 'script' => 'list.php', |
|
| 289 | + 'order' => 19, |
|
| 290 | + 'name' => $l->t('Pending shares'), |
|
| 291 | + ]); |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + // show_Quick_Access stored as string |
|
| 295 | + \OCA\Files\App::getNavigationManager()->add([ |
|
| 296 | + 'id' => 'shareoverview', |
|
| 297 | + 'appname' => 'files_sharing', |
|
| 298 | + 'script' => 'list.php', |
|
| 299 | + 'order' => 18, |
|
| 300 | + 'name' => $l->t('Shares'), |
|
| 301 | + 'classes' => 'collapsible', |
|
| 302 | + 'sublist' => $sharingSublistArray, |
|
| 303 | + 'expandedState' => 'show_sharing_menu' |
|
| 304 | + ]); |
|
| 305 | + } |
|
| 306 | 306 | } |
@@ -37,59 +37,59 @@ |
||
| 37 | 37 | |
| 38 | 38 | class ShareInteractionListener implements IEventListener { |
| 39 | 39 | |
| 40 | - private const SUPPORTED_SHARE_TYPES = [ |
|
| 41 | - IShare::TYPE_USER, |
|
| 42 | - IShare::TYPE_EMAIL, |
|
| 43 | - IShare::TYPE_REMOTE, |
|
| 44 | - ]; |
|
| 40 | + private const SUPPORTED_SHARE_TYPES = [ |
|
| 41 | + IShare::TYPE_USER, |
|
| 42 | + IShare::TYPE_EMAIL, |
|
| 43 | + IShare::TYPE_REMOTE, |
|
| 44 | + ]; |
|
| 45 | 45 | |
| 46 | - /** @var IEventDispatcher */ |
|
| 47 | - private $dispatcher; |
|
| 46 | + /** @var IEventDispatcher */ |
|
| 47 | + private $dispatcher; |
|
| 48 | 48 | |
| 49 | - /** @var IUserManager */ |
|
| 50 | - private $userManager; |
|
| 49 | + /** @var IUserManager */ |
|
| 50 | + private $userManager; |
|
| 51 | 51 | |
| 52 | - /** @var ILogger */ |
|
| 53 | - private $logger; |
|
| 52 | + /** @var ILogger */ |
|
| 53 | + private $logger; |
|
| 54 | 54 | |
| 55 | - public function __construct(IEventDispatcher $dispatcher, |
|
| 56 | - IUserManager $userManager, |
|
| 57 | - ILogger $logger) { |
|
| 58 | - $this->dispatcher = $dispatcher; |
|
| 59 | - $this->userManager = $userManager; |
|
| 60 | - $this->logger = $logger; |
|
| 61 | - } |
|
| 55 | + public function __construct(IEventDispatcher $dispatcher, |
|
| 56 | + IUserManager $userManager, |
|
| 57 | + ILogger $logger) { |
|
| 58 | + $this->dispatcher = $dispatcher; |
|
| 59 | + $this->userManager = $userManager; |
|
| 60 | + $this->logger = $logger; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function handle(Event $event): void { |
|
| 64 | - if (!($event instanceof ShareCreatedEvent)) { |
|
| 65 | - // Unrelated |
|
| 66 | - return; |
|
| 67 | - } |
|
| 63 | + public function handle(Event $event): void { |
|
| 64 | + if (!($event instanceof ShareCreatedEvent)) { |
|
| 65 | + // Unrelated |
|
| 66 | + return; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $share = $event->getShare(); |
|
| 70 | - if (!in_array($share->getShareType(), self::SUPPORTED_SHARE_TYPES, true)) { |
|
| 71 | - $this->logger->debug('Share type does not allow to emit interaction event'); |
|
| 72 | - return; |
|
| 73 | - } |
|
| 74 | - $actor = $this->userManager->get($share->getSharedBy()); |
|
| 75 | - if ($actor === null) { |
|
| 76 | - $this->logger->warning('Share was not created by a user, can\'t emit interaction event'); |
|
| 77 | - return; |
|
| 78 | - } |
|
| 79 | - $interactionEvent = new ContactInteractedWithEvent($actor); |
|
| 80 | - switch ($share->getShareType()) { |
|
| 81 | - case IShare::TYPE_USER: |
|
| 82 | - $interactionEvent->setUid($share->getSharedWith()); |
|
| 83 | - break; |
|
| 84 | - case IShare::TYPE_EMAIL: |
|
| 85 | - $interactionEvent->setEmail($share->getSharedWith()); |
|
| 86 | - break; |
|
| 87 | - case IShare::TYPE_REMOTE: |
|
| 88 | - $interactionEvent->setFederatedCloudId($share->getSharedWith()); |
|
| 89 | - break; |
|
| 90 | - } |
|
| 69 | + $share = $event->getShare(); |
|
| 70 | + if (!in_array($share->getShareType(), self::SUPPORTED_SHARE_TYPES, true)) { |
|
| 71 | + $this->logger->debug('Share type does not allow to emit interaction event'); |
|
| 72 | + return; |
|
| 73 | + } |
|
| 74 | + $actor = $this->userManager->get($share->getSharedBy()); |
|
| 75 | + if ($actor === null) { |
|
| 76 | + $this->logger->warning('Share was not created by a user, can\'t emit interaction event'); |
|
| 77 | + return; |
|
| 78 | + } |
|
| 79 | + $interactionEvent = new ContactInteractedWithEvent($actor); |
|
| 80 | + switch ($share->getShareType()) { |
|
| 81 | + case IShare::TYPE_USER: |
|
| 82 | + $interactionEvent->setUid($share->getSharedWith()); |
|
| 83 | + break; |
|
| 84 | + case IShare::TYPE_EMAIL: |
|
| 85 | + $interactionEvent->setEmail($share->getSharedWith()); |
|
| 86 | + break; |
|
| 87 | + case IShare::TYPE_REMOTE: |
|
| 88 | + $interactionEvent->setFederatedCloudId($share->getSharedWith()); |
|
| 89 | + break; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $this->dispatcher->dispatchTyped($interactionEvent); |
|
| 93 | - } |
|
| 92 | + $this->dispatcher->dispatchTyped($interactionEvent); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | } |