Completed
Pull Request — master (#9345)
by Björn
26:01 queued 08:55
created
lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@
 block discarded – undo
26 26
 
27 27
 class ProviderCouldNotAddShareException extends HintException {
28 28
 
29
-	public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, \Exception $previous = null) {
30
-		parent::__construct($message, $hint, $code, $previous);
31
-	}
29
+    public function __construct($message, $hint = '', $code = Http::STATUS_BAD_REQUEST, \Exception $previous = null) {
30
+        parent::__construct($message, $hint, $code, $previous);
31
+    }
32 32
 
33 33
 
34 34
 }
Please login to merge, or discard this patch.
lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@
 block discarded – undo
25 25
 
26 26
 class ProviderDoesNotExistsException extends HintException {
27 27
 
28
-	/**
29
-	 * ProviderDoesNotExistsException constructor.
30
-	 *
31
-	 * @param string $providerId cloud federation provider ID
32
-	 */
33
-	public function __construct($providerId) {
34
-		$l = \OC::$server->getL10N('federation');
35
-		$message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
36
-		$hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
37
-		parent::__construct($message, $hint);
38
-	}
28
+    /**
29
+     * ProviderDoesNotExistsException constructor.
30
+     *
31
+     * @param string $providerId cloud federation provider ID
32
+     */
33
+    public function __construct($providerId) {
34
+        $l = \OC::$server->getL10N('federation');
35
+        $message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
36
+        $hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
37
+        parent::__construct($message, $hint);
38
+    }
39 39
 
40 40
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 	 */
33 33
 	public function __construct($providerId) {
34 34
 		$l = \OC::$server->getL10N('federation');
35
-		$message = 'Cloud Federation Provider with ID: "' . $providerId . '" does not exist.';
35
+		$message = 'Cloud Federation Provider with ID: "'.$providerId.'" does not exist.';
36 36
 		$hint = $l->t('Cloud Federation Provider with ID: "%s" does not exist.', [$providerId]);
37 37
 		parent::__construct($message, $hint);
38 38
 	}
Please login to merge, or discard this patch.
lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
 
26 26
 class ProviderAlreadyExistsException extends HintException {
27 27
 
28
-	/**
29
-	 * ProviderAlreadyExistsException constructor.
30
-	 *
31
-	 * @param string $newProviderId cloud federation provider ID of the new provider
32
-	 * @param string $existingProviderName name of cloud federation provider which already use the same ID
33
-	 */
34
-	public function __construct($newProviderId, $existingProviderName) {
35
-		$l = \OC::$server->getL10N('federation');
36
-		$message = 'Id "' . $newProviderId . '" already used by cloud federation provider "' . $existingProviderName . '"';
37
-		$hint = $l->t('Id "%s" already used by cloud federation provider "%s"', [$newProviderId, $existingProviderName]);
38
-		parent::__construct($message, $hint);
39
-	}
28
+    /**
29
+     * ProviderAlreadyExistsException constructor.
30
+     *
31
+     * @param string $newProviderId cloud federation provider ID of the new provider
32
+     * @param string $existingProviderName name of cloud federation provider which already use the same ID
33
+     */
34
+    public function __construct($newProviderId, $existingProviderName) {
35
+        $l = \OC::$server->getL10N('federation');
36
+        $message = 'Id "' . $newProviderId . '" already used by cloud federation provider "' . $existingProviderName . '"';
37
+        $hint = $l->t('Id "%s" already used by cloud federation provider "%s"', [$newProviderId, $existingProviderName]);
38
+        parent::__construct($message, $hint);
39
+    }
40 40
 
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 */
34 34
 	public function __construct($newProviderId, $existingProviderName) {
35 35
 		$l = \OC::$server->getL10N('federation');
36
-		$message = 'Id "' . $newProviderId . '" already used by cloud federation provider "' . $existingProviderName . '"';
36
+		$message = 'Id "'.$newProviderId.'" already used by cloud federation provider "'.$existingProviderName.'"';
37 37
 		$hint = $l->t('Id "%s" already used by cloud federation provider "%s"', [$newProviderId, $existingProviderName]);
38 38
 		parent::__construct($message, $hint);
39 39
 	}
Please login to merge, or discard this patch.
lib/public/Federation/ICloudFederationFactory.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,33 +23,33 @@
 block discarded – undo
23 23
 
24 24
 interface ICloudFederationFactory {
25 25
 
26
-	/**
27
-	 * get a CloudFederationShare Object to prepare a share you want to send
28
-	 *
29
-	 * @param string $shareWith
30
-	 * @param string $name resource name (e.g. document.odt)
31
-	 * @param string $description share description (optional)
32
-	 * @param string $providerId resource UID on the provider side
33
-	 * @param string $owner provider specific UID of the user who owns the resource
34
-	 * @param string $ownerDisplayName display name of the user who shared the item
35
-	 * @param string $sharedBy provider specific UID of the user who shared the resource
36
-	 * @param $sharedByDisplayName display name of the user who shared the resource
37
-	 * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
38
-	 * @param string $shareType ('group' or 'user' share)
39
-	 * @param $resourceType ('file', 'calendar',...)
40
-	 * @return ICloudFederationShare
41
-	 *
42
-	 * @since 14.0.0
43
-	 */
44
-	public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
26
+    /**
27
+     * get a CloudFederationShare Object to prepare a share you want to send
28
+     *
29
+     * @param string $shareWith
30
+     * @param string $name resource name (e.g. document.odt)
31
+     * @param string $description share description (optional)
32
+     * @param string $providerId resource UID on the provider side
33
+     * @param string $owner provider specific UID of the user who owns the resource
34
+     * @param string $ownerDisplayName display name of the user who shared the item
35
+     * @param string $sharedBy provider specific UID of the user who shared the resource
36
+     * @param $sharedByDisplayName display name of the user who shared the resource
37
+     * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
38
+     * @param string $shareType ('group' or 'user' share)
39
+     * @param $resourceType ('file', 'calendar',...)
40
+     * @return ICloudFederationShare
41
+     *
42
+     * @since 14.0.0
43
+     */
44
+    public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
45 45
 
46
-	/**
47
-	 * get a Cloud FederationNotification object to prepare a notification you
48
-	 * want to send
49
-	 *
50
-	 * @return ICloudFederationNotification
51
-	 *
52
-	 * @since 14.0.0
53
-	 */
54
-	public function getCloudFederationNotification();
46
+    /**
47
+     * get a Cloud FederationNotification object to prepare a notification you
48
+     * want to send
49
+     *
50
+     * @return ICloudFederationNotification
51
+     *
52
+     * @since 14.0.0
53
+     */
54
+    public function getCloudFederationNotification();
55 55
 }
Please login to merge, or discard this patch.
lib/private/Federation/CloudFederationFactory.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -27,37 +27,37 @@
 block discarded – undo
27 27
 
28 28
 class CloudFederationFactory implements ICloudFederationFactory {
29 29
 
30
-	/**
31
-	 * get a CloudFederationShare Object to prepare a share you want to send
32
-	 *
33
-	 * @param string $shareWith
34
-	 * @param string $name resource name (e.g. document.odt)
35
-	 * @param string $description share description (optional)
36
-	 * @param string $providerId resource UID on the provider side
37
-	 * @param string $owner provider specific UID of the user who owns the resource
38
-	 * @param string $ownerDisplayName display name of the user who shared the item
39
-	 * @param string $sharedBy provider specific UID of the user who shared the resource
40
-	 * @param $sharedByDisplayName display name of the user who shared the resource
41
-	 * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
42
-	 * @param string $shareType ('group' or 'user' share)
43
-	 * @param $resourceType ('file', 'calendar',...)
44
-	 * @return ICloudFederationShare
45
-	 *
46
-	 * @since 14.0.0
47
-	 */
48
-	public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) {
49
-		return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
50
-	}
30
+    /**
31
+     * get a CloudFederationShare Object to prepare a share you want to send
32
+     *
33
+     * @param string $shareWith
34
+     * @param string $name resource name (e.g. document.odt)
35
+     * @param string $description share description (optional)
36
+     * @param string $providerId resource UID on the provider side
37
+     * @param string $owner provider specific UID of the user who owns the resource
38
+     * @param string $ownerDisplayName display name of the user who shared the item
39
+     * @param string $sharedBy provider specific UID of the user who shared the resource
40
+     * @param $sharedByDisplayName display name of the user who shared the resource
41
+     * @param array $protocol (e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]])
42
+     * @param string $shareType ('group' or 'user' share)
43
+     * @param $resourceType ('file', 'calendar',...)
44
+     * @return ICloudFederationShare
45
+     *
46
+     * @since 14.0.0
47
+     */
48
+    public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) {
49
+        return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType);
50
+    }
51 51
 
52
-	/**
53
-	 * get a Cloud FederationNotification object to prepare a notification you
54
-	 * want to send
55
-	 *
56
-	 * @return ICloudFederationNotification
57
-	 *
58
-	 * @since 14.0.0
59
-	 */
60
-	public function getCloudFederationNotification() {
61
-		return new CloudFederationNotification();
62
-	}
52
+    /**
53
+     * get a Cloud FederationNotification object to prepare a notification you
54
+     * want to send
55
+     *
56
+     * @return ICloudFederationNotification
57
+     *
58
+     * @since 14.0.0
59
+     */
60
+    public function getCloudFederationNotification() {
61
+        return new CloudFederationNotification();
62
+    }
63 63
 }
Please login to merge, or discard this patch.
core/routes.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -36,47 +36,47 @@  discard block
 block discarded – undo
36 36
 
37 37
 $application = new Application();
38 38
 $application->registerRoutes($this, [
39
-	'routes' => [
40
-		['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
41
-		['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
42
-		['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
43
-		['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
44
-		['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
45
-		['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
46
-		['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
47
-		['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
48
-		['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
49
-		['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
50
-		['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
51
-		['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
52
-		['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
53
-		['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
54
-		['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
55
-		['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'],
56
-		['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
57
-		['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
58
-		['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
59
-		['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
60
-		['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
61
-		['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
62
-		['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
63
-		['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
64
-		['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
65
-		['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
66
-		['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
67
-		['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
68
-		['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'],
69
-		['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'],
70
-	],
71
-	'ocs' => [
72
-		['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
73
-		['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
74
-		['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
75
-		['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
76
-		['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'],
77
-		['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'],
78
-		['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'],
79
-	],
39
+    'routes' => [
40
+        ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
41
+        ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
42
+        ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
43
+        ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
44
+        ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
45
+        ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
46
+        ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
47
+        ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
48
+        ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
49
+        ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
50
+        ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
51
+        ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
52
+        ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
53
+        ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
54
+        ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
55
+        ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'],
56
+        ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
57
+        ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
58
+        ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
59
+        ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
60
+        ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
61
+        ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
62
+        ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
63
+        ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
64
+        ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
65
+        ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
66
+        ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
67
+        ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
68
+        ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'],
69
+        ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'],
70
+    ],
71
+    'ocs' => [
72
+        ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
73
+        ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
74
+        ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
75
+        ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
76
+        ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'],
77
+        ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'],
78
+        ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'],
79
+    ],
80 80
 ]);
81 81
 
82 82
 // Post installation check
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 // Core ajax actions
86 86
 // Routing
87 87
 $this->create('core_ajax_update', '/core/ajax/update.php')
88
-	->actionInclude('core/ajax/update.php');
88
+    ->actionInclude('core/ajax/update.php');
89 89
 
90 90
 // File routes
91 91
 $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) {
92
-	$app = new \OCA\Files\AppInfo\Application($urlParams);
93
-	$app->dispatch('ViewController', 'index');
92
+    $app = new \OCA\Files\AppInfo\Application($urlParams);
93
+    $app->dispatch('ViewController', 'index');
94 94
 });
95 95
 
96 96
 // Call routes
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
  * @suppress PhanUndeclaredClassMethod
100 100
  */
101 101
 $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) {
102
-	if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) {
103
-		$app = new \OCA\Spreed\AppInfo\Application($urlParams);
104
-		$app->dispatch('PageController', 'index');
105
-	} else {
106
-		throw new \OC\HintException('App spreed is not enabled');
107
-	}
102
+    if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) {
103
+        $app = new \OCA\Spreed\AppInfo\Application($urlParams);
104
+        $app->dispatch('PageController', 'index');
105
+    } else {
106
+        throw new \OC\HintException('App spreed is not enabled');
107
+    }
108 108
 });
109 109
 
110 110
 // OCM routes
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
  * @suppress PhanUndeclaredClassMethod
114 114
  */
115 115
 $this->create('cloud_federation_api.requesthandlercontroller.addShare', '/ocm/shares')->post()->action(function($urlParams) {
116
-	if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
117
-		$app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
118
-		$app->dispatch('RequestHandlerController', 'addShare');
119
-	} else {
120
-		throw new \OC\HintException('Cloud Federation API not enabled');
121
-	}
116
+    if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
117
+        $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
118
+        $app->dispatch('RequestHandlerController', 'addShare');
119
+    } else {
120
+        throw new \OC\HintException('Cloud Federation API not enabled');
121
+    }
122 122
 });
123 123
 
124 124
 /**
@@ -126,53 +126,53 @@  discard block
 block discarded – undo
126 126
  * @suppress PhanUndeclaredClassMethod
127 127
  */
128 128
 $this->create('cloud_federation_api.requesthandlercontroller.receiveNotification', '/ocm/notifications')->post()->action(function($urlParams) {
129
-	if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
130
-		$app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
131
-		$app->dispatch('RequestHandlerController', 'receiveNotification');
132
-	} else {
133
-		throw new \OC\HintException('Cloud Federation API not enabled');
134
-	}
129
+    if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
130
+        $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
131
+        $app->dispatch('RequestHandlerController', 'receiveNotification');
132
+    } else {
133
+        throw new \OC\HintException('Cloud Federation API not enabled');
134
+    }
135 135
 });
136 136
 
137 137
 
138 138
 // Sharing routes
139 139
 $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) {
140
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
141
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
142
-		$app->dispatch('ShareController', 'showShare');
143
-	} else {
144
-		throw new \OC\HintException('App file sharing is not enabled');
145
-	}
140
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
141
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
142
+        $app->dispatch('ShareController', 'showShare');
143
+    } else {
144
+        throw new \OC\HintException('App file sharing is not enabled');
145
+    }
146 146
 });
147 147
 $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate/{redirect}')->post()->action(function($urlParams) {
148
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
149
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
150
-		$app->dispatch('ShareController', 'authenticate');
151
-	} else {
152
-		throw new \OC\HintException('App file sharing is not enabled');
153
-	}
148
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
149
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
150
+        $app->dispatch('ShareController', 'authenticate');
151
+    } else {
152
+        throw new \OC\HintException('App file sharing is not enabled');
153
+    }
154 154
 });
155 155
 $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate/{redirect}')->get()->action(function($urlParams) {
156
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
157
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
158
-		$app->dispatch('ShareController', 'showAuthenticate');
159
-	} else {
160
-		throw new \OC\HintException('App file sharing is not enabled');
161
-	}
156
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
157
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
158
+        $app->dispatch('ShareController', 'showAuthenticate');
159
+    } else {
160
+        throw new \OC\HintException('App file sharing is not enabled');
161
+    }
162 162
 });
163 163
 $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) {
164
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
165
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
166
-		$app->dispatch('ShareController', 'downloadShare');
167
-	} else {
168
-		throw new \OC\HintException('App file sharing is not enabled');
169
-	}
164
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
165
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
166
+        $app->dispatch('ShareController', 'downloadShare');
167
+    } else {
168
+        throw new \OC\HintException('App file sharing is not enabled');
169
+    }
170 170
 });
171 171
 $this->create('files_sharing.publicpreview.directLink', '/s/{token}/preview')->get()->action(function($urlParams) {
172
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
173
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
174
-		$app->dispatch('PublicPreviewController', 'directLink');
175
-	} else {
176
-		throw new \OC\HintException('App file sharing is not enabled');
177
-	}
172
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
173
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
174
+        $app->dispatch('PublicPreviewController', 'directLink');
175
+    } else {
176
+        throw new \OC\HintException('App file sharing is not enabled');
177
+    }
178 178
 });
Please login to merge, or discard this patch.
lib/public/IServerContainer.php 1 patch
Indentation   +505 added lines, -505 removed lines patch added patch discarded remove patch
@@ -60,509 +60,509 @@
 block discarded – undo
60 60
  */
61 61
 interface IServerContainer extends IContainer {
62 62
 
63
-	/**
64
-	 * The calendar manager will act as a broker between consumers for calendar information and
65
-	 * providers which actual deliver the calendar information.
66
-	 *
67
-	 * @return \OCP\Calendar\IManager
68
-	 * @since 13.0.0
69
-	 */
70
-	public function getCalendarManager();
71
-
72
-	/**
73
-	 * The contacts manager will act as a broker between consumers for contacts information and
74
-	 * providers which actual deliver the contact information.
75
-	 *
76
-	 * @return \OCP\Contacts\IManager
77
-	 * @since 6.0.0
78
-	 */
79
-	public function getContactsManager();
80
-
81
-	/**
82
-	 * The current request object holding all information about the request currently being processed
83
-	 * is returned from this method.
84
-	 * In case the current execution was not initiated by a web request null is returned
85
-	 *
86
-	 * @return \OCP\IRequest
87
-	 * @since 6.0.0
88
-	 */
89
-	public function getRequest();
90
-
91
-	/**
92
-	 * Returns the preview manager which can create preview images for a given file
93
-	 *
94
-	 * @return \OCP\IPreview
95
-	 * @since 6.0.0
96
-	 */
97
-	public function getPreviewManager();
98
-
99
-	/**
100
-	 * Returns the tag manager which can get and set tags for different object types
101
-	 *
102
-	 * @see \OCP\ITagManager::load()
103
-	 * @return \OCP\ITagManager
104
-	 * @since 6.0.0
105
-	 */
106
-	public function getTagManager();
107
-
108
-	/**
109
-	 * Returns the root folder of ownCloud's data directory
110
-	 *
111
-	 * @return \OCP\Files\IRootFolder
112
-	 * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder
113
-	 */
114
-	public function getRootFolder();
115
-
116
-	/**
117
-	 * Returns a view to ownCloud's files folder
118
-	 *
119
-	 * @param string $userId user ID
120
-	 * @return \OCP\Files\Folder
121
-	 * @since 6.0.0 - parameter $userId was added in 8.0.0
122
-	 * @see getUserFolder in \OCP\Files\IRootFolder
123
-	 */
124
-	public function getUserFolder($userId = null);
125
-
126
-	/**
127
-	 * Returns an app-specific view in ownClouds data directory
128
-	 *
129
-	 * @return \OCP\Files\Folder
130
-	 * @since 6.0.0
131
-	 * @deprecated 9.2.0 use IAppData
132
-	 */
133
-	public function getAppFolder();
134
-
135
-	/**
136
-	 * Returns a user manager
137
-	 *
138
-	 * @return \OCP\IUserManager
139
-	 * @since 8.0.0
140
-	 */
141
-	public function getUserManager();
142
-
143
-	/**
144
-	 * Returns a group manager
145
-	 *
146
-	 * @return \OCP\IGroupManager
147
-	 * @since 8.0.0
148
-	 */
149
-	public function getGroupManager();
150
-
151
-	/**
152
-	 * Returns the user session
153
-	 *
154
-	 * @return \OCP\IUserSession
155
-	 * @since 6.0.0
156
-	 */
157
-	public function getUserSession();
158
-
159
-	/**
160
-	 * Returns the navigation manager
161
-	 *
162
-	 * @return \OCP\INavigationManager
163
-	 * @since 6.0.0
164
-	 */
165
-	public function getNavigationManager();
166
-
167
-	/**
168
-	 * Returns the config manager
169
-	 *
170
-	 * @return \OCP\IConfig
171
-	 * @since 6.0.0
172
-	 */
173
-	public function getConfig();
174
-
175
-	/**
176
-	 * Returns a Crypto instance
177
-	 *
178
-	 * @return \OCP\Security\ICrypto
179
-	 * @since 8.0.0
180
-	 */
181
-	public function getCrypto();
182
-
183
-	/**
184
-	 * Returns a Hasher instance
185
-	 *
186
-	 * @return \OCP\Security\IHasher
187
-	 * @since 8.0.0
188
-	 */
189
-	public function getHasher();
190
-
191
-	/**
192
-	 * Returns a SecureRandom instance
193
-	 *
194
-	 * @return \OCP\Security\ISecureRandom
195
-	 * @since 8.1.0
196
-	 */
197
-	public function getSecureRandom();
198
-
199
-	/**
200
-	 * Returns a CredentialsManager instance
201
-	 *
202
-	 * @return \OCP\Security\ICredentialsManager
203
-	 * @since 9.0.0
204
-	 */
205
-	public function getCredentialsManager();
206
-
207
-	/**
208
-	 * Returns the app config manager
209
-	 *
210
-	 * @return \OCP\IAppConfig
211
-	 * @since 7.0.0
212
-	 */
213
-	public function getAppConfig();
214
-
215
-	/**
216
-	 * @return \OCP\L10N\IFactory
217
-	 * @since 8.2.0
218
-	 */
219
-	public function getL10NFactory();
220
-
221
-	/**
222
-	 * get an L10N instance
223
-	 * @param string $app appid
224
-	 * @param string $lang
225
-	 * @return \OCP\IL10N
226
-	 * @since 6.0.0 - parameter $lang was added in 8.0.0
227
-	 */
228
-	public function getL10N($app, $lang = null);
229
-
230
-	/**
231
-	 * @return \OC\Encryption\Manager
232
-	 * @since 8.1.0
233
-	 */
234
-	public function getEncryptionManager();
235
-
236
-	/**
237
-	 * @return \OC\Encryption\File
238
-	 * @since 8.1.0
239
-	 */
240
-	public function getEncryptionFilesHelper();
241
-
242
-	/**
243
-	 * @return \OCP\Encryption\Keys\IStorage
244
-	 * @since 8.1.0
245
-	 */
246
-	public function getEncryptionKeyStorage();
247
-
248
-	/**
249
-	 * Returns the URL generator
250
-	 *
251
-	 * @return \OCP\IURLGenerator
252
-	 * @since 6.0.0
253
-	 */
254
-	public function getURLGenerator();
255
-
256
-	/**
257
-	 * Returns an ICache instance
258
-	 *
259
-	 * @return \OCP\ICache
260
-	 * @since 6.0.0
261
-	 */
262
-	public function getCache();
263
-
264
-	/**
265
-	 * Returns an \OCP\CacheFactory instance
266
-	 *
267
-	 * @return \OCP\ICacheFactory
268
-	 * @since 7.0.0
269
-	 */
270
-	public function getMemCacheFactory();
271
-
272
-	/**
273
-	 * Returns the current session
274
-	 *
275
-	 * @return \OCP\ISession
276
-	 * @since 6.0.0
277
-	 */
278
-	public function getSession();
279
-
280
-	/**
281
-	 * Returns the activity manager
282
-	 *
283
-	 * @return \OCP\Activity\IManager
284
-	 * @since 6.0.0
285
-	 */
286
-	public function getActivityManager();
287
-
288
-	/**
289
-	 * Returns the current session
290
-	 *
291
-	 * @return \OCP\IDBConnection
292
-	 * @since 6.0.0
293
-	 */
294
-	public function getDatabaseConnection();
295
-
296
-	/**
297
-	 * Returns an avatar manager, used for avatar functionality
298
-	 *
299
-	 * @return \OCP\IAvatarManager
300
-	 * @since 6.0.0
301
-	 */
302
-	public function getAvatarManager();
303
-
304
-	/**
305
-	 * Returns an job list for controlling background jobs
306
-	 *
307
-	 * @return \OCP\BackgroundJob\IJobList
308
-	 * @since 7.0.0
309
-	 */
310
-	public function getJobList();
311
-
312
-	/**
313
-	 * Returns a logger instance
314
-	 *
315
-	 * @return \OCP\ILogger
316
-	 * @since 8.0.0
317
-	 */
318
-	public function getLogger();
319
-
320
-	/**
321
-	 * returns a log factory instance
322
-	 *
323
-	 * @return ILogFactory
324
-	 * @since 14.0.0
325
-	 */
326
-	public function getLogFactory();
327
-
328
-	/**
329
-	 * Returns a router for generating and matching urls
330
-	 *
331
-	 * @return \OCP\Route\IRouter
332
-	 * @since 7.0.0
333
-	 */
334
-	public function getRouter();
335
-
336
-	/**
337
-	 * Returns a search instance
338
-	 *
339
-	 * @return \OCP\ISearch
340
-	 * @since 7.0.0
341
-	 */
342
-	public function getSearch();
343
-
344
-	/**
345
-	 * Get the certificate manager for the user
346
-	 *
347
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
348
-	 * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in
349
-	 * @since 8.0.0
350
-	 */
351
-	public function getCertificateManager($userId = null);
352
-
353
-	/**
354
-	 * Create a new event source
355
-	 *
356
-	 * @return \OCP\IEventSource
357
-	 * @since 8.0.0
358
-	 */
359
-	public function createEventSource();
360
-
361
-	/**
362
-	 * Returns an instance of the HTTP client service
363
-	 *
364
-	 * @return \OCP\Http\Client\IClientService
365
-	 * @since 8.1.0
366
-	 */
367
-	public function getHTTPClientService();
368
-
369
-	/**
370
-	 * Get the active event logger
371
-	 *
372
-	 * @return \OCP\Diagnostics\IEventLogger
373
-	 * @since 8.0.0
374
-	 */
375
-	public function getEventLogger();
376
-
377
-	/**
378
-	 * Get the active query logger
379
-	 *
380
-	 * The returned logger only logs data when debug mode is enabled
381
-	 *
382
-	 * @return \OCP\Diagnostics\IQueryLogger
383
-	 * @since 8.0.0
384
-	 */
385
-	public function getQueryLogger();
386
-
387
-	/**
388
-	 * Get the manager for temporary files and folders
389
-	 *
390
-	 * @return \OCP\ITempManager
391
-	 * @since 8.0.0
392
-	 */
393
-	public function getTempManager();
394
-
395
-	/**
396
-	 * Get the app manager
397
-	 *
398
-	 * @return \OCP\App\IAppManager
399
-	 * @since 8.0.0
400
-	 */
401
-	public function getAppManager();
402
-
403
-	/**
404
-	 * Get the webroot
405
-	 *
406
-	 * @return string
407
-	 * @since 8.0.0
408
-	 */
409
-	public function getWebRoot();
410
-
411
-	/**
412
-	 * @return \OCP\Files\Config\IMountProviderCollection
413
-	 * @since 8.0.0
414
-	 */
415
-	public function getMountProviderCollection();
416
-
417
-	/**
418
-	 * Get the IniWrapper
419
-	 *
420
-	 * @return \bantu\IniGetWrapper\IniGetWrapper
421
-	 * @since 8.0.0
422
-	 */
423
-	public function getIniWrapper();
424
-	/**
425
-	 * @return \OCP\Command\IBus
426
-	 * @since 8.1.0
427
-	 */
428
-	public function getCommandBus();
429
-
430
-	/**
431
-	 * Creates a new mailer
432
-	 *
433
-	 * @return \OCP\Mail\IMailer
434
-	 * @since 8.1.0
435
-	 */
436
-	public function getMailer();
437
-
438
-	/**
439
-	 * Get the locking provider
440
-	 *
441
-	 * @return \OCP\Lock\ILockingProvider
442
-	 * @since 8.1.0
443
-	 */
444
-	public function getLockingProvider();
445
-
446
-	/**
447
-	 * @return \OCP\Files\Mount\IMountManager
448
-	 * @since 8.2.0
449
-	 */
450
-	public function getMountManager();
451
-
452
-	/**
453
-	 * Get the MimeTypeDetector
454
-	 *
455
-	 * @return \OCP\Files\IMimeTypeDetector
456
-	 * @since 8.2.0
457
-	 */
458
-	public function getMimeTypeDetector();
459
-
460
-	/**
461
-	 * Get the MimeTypeLoader
462
-	 *
463
-	 * @return \OCP\Files\IMimeTypeLoader
464
-	 * @since 8.2.0
465
-	 */
466
-	public function getMimeTypeLoader();
467
-
468
-	/**
469
-	 * Get the EventDispatcher
470
-	 *
471
-	 * @return EventDispatcherInterface
472
-	 * @since 8.2.0
473
-	 */
474
-	public function getEventDispatcher();
475
-
476
-	/**
477
-	 * Get the Notification Manager
478
-	 *
479
-	 * @return \OCP\Notification\IManager
480
-	 * @since 9.0.0
481
-	 */
482
-	public function getNotificationManager();
483
-
484
-	/**
485
-	 * @return \OCP\Comments\ICommentsManager
486
-	 * @since 9.0.0
487
-	 */
488
-	public function getCommentsManager();
489
-
490
-	/**
491
-	 * Returns the system-tag manager
492
-	 *
493
-	 * @return \OCP\SystemTag\ISystemTagManager
494
-	 *
495
-	 * @since 9.0.0
496
-	 */
497
-	public function getSystemTagManager();
498
-
499
-	/**
500
-	 * Returns the system-tag object mapper
501
-	 *
502
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
503
-	 *
504
-	 * @since 9.0.0
505
-	 */
506
-	public function getSystemTagObjectMapper();
507
-
508
-	/**
509
-	 * Returns the share manager
510
-	 *
511
-	 * @return \OCP\Share\IManager
512
-	 * @since 9.0.0
513
-	 */
514
-	public function getShareManager();
515
-
516
-	/**
517
-	 * @return IContentSecurityPolicyManager
518
-	 * @since 9.0.0
519
-	 */
520
-	public function getContentSecurityPolicyManager();
521
-
522
-	/**
523
-	 * @return \OCP\IDateTimeZone
524
-	 * @since 8.0.0
525
-	 */
526
-	public function getDateTimeZone();
527
-
528
-	/**
529
-	 * @return \OCP\IDateTimeFormatter
530
-	 * @since 8.0.0
531
-	 */
532
-	public function getDateTimeFormatter();
533
-
534
-	/**
535
-	 * @return \OCP\Federation\ICloudIdManager
536
-	 * @since 12.0.0
537
-	 */
538
-	public function getCloudIdManager();
539
-
540
-	/**
541
-	 * @return \OCP\GlobalScale\IConfig
542
-	 */
543
-	public function getGlobalScaleConfig();
544
-
545
-	/**
546
-	 * @return ICloudFederationFactory
547
-	 * @since 14.0.0
548
-	 */
549
-	public function getCloudFederationFactory();
550
-
551
-	/**
552
-	 * @return ICloudFederationProviderManager
553
-	 * @since 14.0.0
554
-	 */
555
-	public function getCloudFederationProviderManager();
556
-
557
-	/**
558
-	 * @return \OCP\Remote\Api\IApiFactory
559
-	 * @since 13.0.0
560
-	 */
561
-	public function getRemoteApiFactory();
562
-
563
-	/**
564
-	 * @return \OCP\Remote\IInstanceFactory
565
-	 * @since 13.0.0
566
-	 */
567
-	public function getRemoteInstanceFactory();
63
+    /**
64
+     * The calendar manager will act as a broker between consumers for calendar information and
65
+     * providers which actual deliver the calendar information.
66
+     *
67
+     * @return \OCP\Calendar\IManager
68
+     * @since 13.0.0
69
+     */
70
+    public function getCalendarManager();
71
+
72
+    /**
73
+     * The contacts manager will act as a broker between consumers for contacts information and
74
+     * providers which actual deliver the contact information.
75
+     *
76
+     * @return \OCP\Contacts\IManager
77
+     * @since 6.0.0
78
+     */
79
+    public function getContactsManager();
80
+
81
+    /**
82
+     * The current request object holding all information about the request currently being processed
83
+     * is returned from this method.
84
+     * In case the current execution was not initiated by a web request null is returned
85
+     *
86
+     * @return \OCP\IRequest
87
+     * @since 6.0.0
88
+     */
89
+    public function getRequest();
90
+
91
+    /**
92
+     * Returns the preview manager which can create preview images for a given file
93
+     *
94
+     * @return \OCP\IPreview
95
+     * @since 6.0.0
96
+     */
97
+    public function getPreviewManager();
98
+
99
+    /**
100
+     * Returns the tag manager which can get and set tags for different object types
101
+     *
102
+     * @see \OCP\ITagManager::load()
103
+     * @return \OCP\ITagManager
104
+     * @since 6.0.0
105
+     */
106
+    public function getTagManager();
107
+
108
+    /**
109
+     * Returns the root folder of ownCloud's data directory
110
+     *
111
+     * @return \OCP\Files\IRootFolder
112
+     * @since 6.0.0 - between 6.0.0 and 8.0.0 this returned \OCP\Files\Folder
113
+     */
114
+    public function getRootFolder();
115
+
116
+    /**
117
+     * Returns a view to ownCloud's files folder
118
+     *
119
+     * @param string $userId user ID
120
+     * @return \OCP\Files\Folder
121
+     * @since 6.0.0 - parameter $userId was added in 8.0.0
122
+     * @see getUserFolder in \OCP\Files\IRootFolder
123
+     */
124
+    public function getUserFolder($userId = null);
125
+
126
+    /**
127
+     * Returns an app-specific view in ownClouds data directory
128
+     *
129
+     * @return \OCP\Files\Folder
130
+     * @since 6.0.0
131
+     * @deprecated 9.2.0 use IAppData
132
+     */
133
+    public function getAppFolder();
134
+
135
+    /**
136
+     * Returns a user manager
137
+     *
138
+     * @return \OCP\IUserManager
139
+     * @since 8.0.0
140
+     */
141
+    public function getUserManager();
142
+
143
+    /**
144
+     * Returns a group manager
145
+     *
146
+     * @return \OCP\IGroupManager
147
+     * @since 8.0.0
148
+     */
149
+    public function getGroupManager();
150
+
151
+    /**
152
+     * Returns the user session
153
+     *
154
+     * @return \OCP\IUserSession
155
+     * @since 6.0.0
156
+     */
157
+    public function getUserSession();
158
+
159
+    /**
160
+     * Returns the navigation manager
161
+     *
162
+     * @return \OCP\INavigationManager
163
+     * @since 6.0.0
164
+     */
165
+    public function getNavigationManager();
166
+
167
+    /**
168
+     * Returns the config manager
169
+     *
170
+     * @return \OCP\IConfig
171
+     * @since 6.0.0
172
+     */
173
+    public function getConfig();
174
+
175
+    /**
176
+     * Returns a Crypto instance
177
+     *
178
+     * @return \OCP\Security\ICrypto
179
+     * @since 8.0.0
180
+     */
181
+    public function getCrypto();
182
+
183
+    /**
184
+     * Returns a Hasher instance
185
+     *
186
+     * @return \OCP\Security\IHasher
187
+     * @since 8.0.0
188
+     */
189
+    public function getHasher();
190
+
191
+    /**
192
+     * Returns a SecureRandom instance
193
+     *
194
+     * @return \OCP\Security\ISecureRandom
195
+     * @since 8.1.0
196
+     */
197
+    public function getSecureRandom();
198
+
199
+    /**
200
+     * Returns a CredentialsManager instance
201
+     *
202
+     * @return \OCP\Security\ICredentialsManager
203
+     * @since 9.0.0
204
+     */
205
+    public function getCredentialsManager();
206
+
207
+    /**
208
+     * Returns the app config manager
209
+     *
210
+     * @return \OCP\IAppConfig
211
+     * @since 7.0.0
212
+     */
213
+    public function getAppConfig();
214
+
215
+    /**
216
+     * @return \OCP\L10N\IFactory
217
+     * @since 8.2.0
218
+     */
219
+    public function getL10NFactory();
220
+
221
+    /**
222
+     * get an L10N instance
223
+     * @param string $app appid
224
+     * @param string $lang
225
+     * @return \OCP\IL10N
226
+     * @since 6.0.0 - parameter $lang was added in 8.0.0
227
+     */
228
+    public function getL10N($app, $lang = null);
229
+
230
+    /**
231
+     * @return \OC\Encryption\Manager
232
+     * @since 8.1.0
233
+     */
234
+    public function getEncryptionManager();
235
+
236
+    /**
237
+     * @return \OC\Encryption\File
238
+     * @since 8.1.0
239
+     */
240
+    public function getEncryptionFilesHelper();
241
+
242
+    /**
243
+     * @return \OCP\Encryption\Keys\IStorage
244
+     * @since 8.1.0
245
+     */
246
+    public function getEncryptionKeyStorage();
247
+
248
+    /**
249
+     * Returns the URL generator
250
+     *
251
+     * @return \OCP\IURLGenerator
252
+     * @since 6.0.0
253
+     */
254
+    public function getURLGenerator();
255
+
256
+    /**
257
+     * Returns an ICache instance
258
+     *
259
+     * @return \OCP\ICache
260
+     * @since 6.0.0
261
+     */
262
+    public function getCache();
263
+
264
+    /**
265
+     * Returns an \OCP\CacheFactory instance
266
+     *
267
+     * @return \OCP\ICacheFactory
268
+     * @since 7.0.0
269
+     */
270
+    public function getMemCacheFactory();
271
+
272
+    /**
273
+     * Returns the current session
274
+     *
275
+     * @return \OCP\ISession
276
+     * @since 6.0.0
277
+     */
278
+    public function getSession();
279
+
280
+    /**
281
+     * Returns the activity manager
282
+     *
283
+     * @return \OCP\Activity\IManager
284
+     * @since 6.0.0
285
+     */
286
+    public function getActivityManager();
287
+
288
+    /**
289
+     * Returns the current session
290
+     *
291
+     * @return \OCP\IDBConnection
292
+     * @since 6.0.0
293
+     */
294
+    public function getDatabaseConnection();
295
+
296
+    /**
297
+     * Returns an avatar manager, used for avatar functionality
298
+     *
299
+     * @return \OCP\IAvatarManager
300
+     * @since 6.0.0
301
+     */
302
+    public function getAvatarManager();
303
+
304
+    /**
305
+     * Returns an job list for controlling background jobs
306
+     *
307
+     * @return \OCP\BackgroundJob\IJobList
308
+     * @since 7.0.0
309
+     */
310
+    public function getJobList();
311
+
312
+    /**
313
+     * Returns a logger instance
314
+     *
315
+     * @return \OCP\ILogger
316
+     * @since 8.0.0
317
+     */
318
+    public function getLogger();
319
+
320
+    /**
321
+     * returns a log factory instance
322
+     *
323
+     * @return ILogFactory
324
+     * @since 14.0.0
325
+     */
326
+    public function getLogFactory();
327
+
328
+    /**
329
+     * Returns a router for generating and matching urls
330
+     *
331
+     * @return \OCP\Route\IRouter
332
+     * @since 7.0.0
333
+     */
334
+    public function getRouter();
335
+
336
+    /**
337
+     * Returns a search instance
338
+     *
339
+     * @return \OCP\ISearch
340
+     * @since 7.0.0
341
+     */
342
+    public function getSearch();
343
+
344
+    /**
345
+     * Get the certificate manager for the user
346
+     *
347
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
348
+     * @return \OCP\ICertificateManager | null if $userId is null and no user is logged in
349
+     * @since 8.0.0
350
+     */
351
+    public function getCertificateManager($userId = null);
352
+
353
+    /**
354
+     * Create a new event source
355
+     *
356
+     * @return \OCP\IEventSource
357
+     * @since 8.0.0
358
+     */
359
+    public function createEventSource();
360
+
361
+    /**
362
+     * Returns an instance of the HTTP client service
363
+     *
364
+     * @return \OCP\Http\Client\IClientService
365
+     * @since 8.1.0
366
+     */
367
+    public function getHTTPClientService();
368
+
369
+    /**
370
+     * Get the active event logger
371
+     *
372
+     * @return \OCP\Diagnostics\IEventLogger
373
+     * @since 8.0.0
374
+     */
375
+    public function getEventLogger();
376
+
377
+    /**
378
+     * Get the active query logger
379
+     *
380
+     * The returned logger only logs data when debug mode is enabled
381
+     *
382
+     * @return \OCP\Diagnostics\IQueryLogger
383
+     * @since 8.0.0
384
+     */
385
+    public function getQueryLogger();
386
+
387
+    /**
388
+     * Get the manager for temporary files and folders
389
+     *
390
+     * @return \OCP\ITempManager
391
+     * @since 8.0.0
392
+     */
393
+    public function getTempManager();
394
+
395
+    /**
396
+     * Get the app manager
397
+     *
398
+     * @return \OCP\App\IAppManager
399
+     * @since 8.0.0
400
+     */
401
+    public function getAppManager();
402
+
403
+    /**
404
+     * Get the webroot
405
+     *
406
+     * @return string
407
+     * @since 8.0.0
408
+     */
409
+    public function getWebRoot();
410
+
411
+    /**
412
+     * @return \OCP\Files\Config\IMountProviderCollection
413
+     * @since 8.0.0
414
+     */
415
+    public function getMountProviderCollection();
416
+
417
+    /**
418
+     * Get the IniWrapper
419
+     *
420
+     * @return \bantu\IniGetWrapper\IniGetWrapper
421
+     * @since 8.0.0
422
+     */
423
+    public function getIniWrapper();
424
+    /**
425
+     * @return \OCP\Command\IBus
426
+     * @since 8.1.0
427
+     */
428
+    public function getCommandBus();
429
+
430
+    /**
431
+     * Creates a new mailer
432
+     *
433
+     * @return \OCP\Mail\IMailer
434
+     * @since 8.1.0
435
+     */
436
+    public function getMailer();
437
+
438
+    /**
439
+     * Get the locking provider
440
+     *
441
+     * @return \OCP\Lock\ILockingProvider
442
+     * @since 8.1.0
443
+     */
444
+    public function getLockingProvider();
445
+
446
+    /**
447
+     * @return \OCP\Files\Mount\IMountManager
448
+     * @since 8.2.0
449
+     */
450
+    public function getMountManager();
451
+
452
+    /**
453
+     * Get the MimeTypeDetector
454
+     *
455
+     * @return \OCP\Files\IMimeTypeDetector
456
+     * @since 8.2.0
457
+     */
458
+    public function getMimeTypeDetector();
459
+
460
+    /**
461
+     * Get the MimeTypeLoader
462
+     *
463
+     * @return \OCP\Files\IMimeTypeLoader
464
+     * @since 8.2.0
465
+     */
466
+    public function getMimeTypeLoader();
467
+
468
+    /**
469
+     * Get the EventDispatcher
470
+     *
471
+     * @return EventDispatcherInterface
472
+     * @since 8.2.0
473
+     */
474
+    public function getEventDispatcher();
475
+
476
+    /**
477
+     * Get the Notification Manager
478
+     *
479
+     * @return \OCP\Notification\IManager
480
+     * @since 9.0.0
481
+     */
482
+    public function getNotificationManager();
483
+
484
+    /**
485
+     * @return \OCP\Comments\ICommentsManager
486
+     * @since 9.0.0
487
+     */
488
+    public function getCommentsManager();
489
+
490
+    /**
491
+     * Returns the system-tag manager
492
+     *
493
+     * @return \OCP\SystemTag\ISystemTagManager
494
+     *
495
+     * @since 9.0.0
496
+     */
497
+    public function getSystemTagManager();
498
+
499
+    /**
500
+     * Returns the system-tag object mapper
501
+     *
502
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
503
+     *
504
+     * @since 9.0.0
505
+     */
506
+    public function getSystemTagObjectMapper();
507
+
508
+    /**
509
+     * Returns the share manager
510
+     *
511
+     * @return \OCP\Share\IManager
512
+     * @since 9.0.0
513
+     */
514
+    public function getShareManager();
515
+
516
+    /**
517
+     * @return IContentSecurityPolicyManager
518
+     * @since 9.0.0
519
+     */
520
+    public function getContentSecurityPolicyManager();
521
+
522
+    /**
523
+     * @return \OCP\IDateTimeZone
524
+     * @since 8.0.0
525
+     */
526
+    public function getDateTimeZone();
527
+
528
+    /**
529
+     * @return \OCP\IDateTimeFormatter
530
+     * @since 8.0.0
531
+     */
532
+    public function getDateTimeFormatter();
533
+
534
+    /**
535
+     * @return \OCP\Federation\ICloudIdManager
536
+     * @since 12.0.0
537
+     */
538
+    public function getCloudIdManager();
539
+
540
+    /**
541
+     * @return \OCP\GlobalScale\IConfig
542
+     */
543
+    public function getGlobalScaleConfig();
544
+
545
+    /**
546
+     * @return ICloudFederationFactory
547
+     * @since 14.0.0
548
+     */
549
+    public function getCloudFederationFactory();
550
+
551
+    /**
552
+     * @return ICloudFederationProviderManager
553
+     * @since 14.0.0
554
+     */
555
+    public function getCloudFederationProviderManager();
556
+
557
+    /**
558
+     * @return \OCP\Remote\Api\IApiFactory
559
+     * @since 13.0.0
560
+     */
561
+    public function getRemoteApiFactory();
562
+
563
+    /**
564
+     * @return \OCP\Remote\IInstanceFactory
565
+     * @since 13.0.0
566
+     */
567
+    public function getRemoteInstanceFactory();
568 568
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/Notifications.php 2 patches
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -33,358 +33,358 @@
 block discarded – undo
33 33
 use OCP\OCS\IDiscoveryService;
34 34
 
35 35
 class Notifications {
36
-	const RESPONSE_FORMAT = 'json'; // default response format for ocs calls
37
-
38
-	/** @var AddressHandler */
39
-	private $addressHandler;
40
-
41
-	/** @var IClientService */
42
-	private $httpClientService;
43
-
44
-	/** @var IDiscoveryService */
45
-	private $discoveryService;
46
-
47
-	/** @var IJobList  */
48
-	private $jobList;
49
-
50
-	/** @var ICloudFederationProviderManager */
51
-	private $federationProviderManager;
52
-
53
-	/** @var ICloudFederationFactory */
54
-	private $cloudFederationFactory;
55
-
56
-	/**
57
-	 * @param AddressHandler $addressHandler
58
-	 * @param IClientService $httpClientService
59
-	 * @param IDiscoveryService $discoveryService
60
-	 * @param IJobList $jobList
61
-	 * @param ICloudFederationProviderManager $federationProviderManager
62
-	 * @param ICloudFederationFactory $cloudFederationFactory
63
-	 */
64
-	public function __construct(
65
-		AddressHandler $addressHandler,
66
-		IClientService $httpClientService,
67
-		IDiscoveryService $discoveryService,
68
-		IJobList $jobList,
69
-		ICloudFederationProviderManager $federationProviderManager,
70
-		ICloudFederationFactory $cloudFederationFactory
71
-	) {
72
-		$this->addressHandler = $addressHandler;
73
-		$this->httpClientService = $httpClientService;
74
-		$this->discoveryService = $discoveryService;
75
-		$this->jobList = $jobList;
76
-		$this->federationProviderManager = $federationProviderManager;
77
-		$this->cloudFederationFactory = $cloudFederationFactory;
78
-	}
79
-
80
-	/**
81
-	 * send server-to-server share to remote server
82
-	 *
83
-	 * @param string $token
84
-	 * @param string $shareWith
85
-	 * @param string $name
86
-	 * @param int $remote_id
87
-	 * @param string $owner
88
-	 * @param string $ownerFederatedId
89
-	 * @param string $sharedBy
90
-	 * @param string $sharedByFederatedId
91
-	 * @return bool
92
-	 * @throws \OC\HintException
93
-	 * @throws \OC\ServerNotAvailableException
94
-	 */
95
-	public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId) {
96
-
97
-		list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
98
-
99
-		if ($user && $remote) {
100
-			$local = $this->addressHandler->generateRemoteURL();
101
-
102
-			$fields = array(
103
-				'shareWith' => $user,
104
-				'token' => $token,
105
-				'name' => $name,
106
-				'remoteId' => $remote_id,
107
-				'owner' => $owner,
108
-				'ownerFederatedId' => $ownerFederatedId,
109
-				'sharedBy' => $sharedBy,
110
-				'sharedByFederatedId' => $sharedByFederatedId,
111
-				'remote' => $local,
112
-			);
113
-
114
-			$result = $this->tryHttpPostToShareEndpoint($remote, '', $fields);
115
-			$status = json_decode($result['result'], true);
116
-
117
-			$ocsStatus = isset($status['ocs']);
118
-			$ocsSuccess = $ocsStatus && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200);
119
-
120
-			if ($result['success'] && (!$ocsStatus ||$ocsSuccess)) {
121
-				\OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $remote]);
122
-				return true;
123
-			}
124
-
125
-		}
126
-
127
-		return false;
128
-	}
129
-
130
-	/**
131
-	 * ask owner to re-share the file with the given user
132
-	 *
133
-	 * @param string $token
134
-	 * @param int $id remote Id
135
-	 * @param int $shareId internal share Id
136
-	 * @param string $remote remote address of the owner
137
-	 * @param string $shareWith
138
-	 * @param int $permission
139
-	 * @return bool
140
-	 * @throws \OC\HintException
141
-	 * @throws \OC\ServerNotAvailableException
142
-	 */
143
-	public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission) {
144
-
145
-		$fields = array(
146
-			'shareWith' => $shareWith,
147
-			'token' => $token,
148
-			'permission' => $permission,
149
-			'remoteId' => $shareId
150
-		);
151
-
152
-		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $id . '/reshare', $fields);
153
-		$status = json_decode($result['result'], true);
154
-
155
-		$httpRequestSuccessful = $result['success'];
156
-		$ocsCallSuccessful = $status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200;
157
-		$validToken = isset($status['ocs']['data']['token']) && is_string($status['ocs']['data']['token']);
158
-		$validRemoteId = isset($status['ocs']['data']['remoteId']);
159
-
160
-		if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) {
161
-			return [
162
-				$status['ocs']['data']['token'],
163
-				(int)$status['ocs']['data']['remoteId']
164
-			];
165
-		}
166
-
167
-		return false;
168
-	}
169
-
170
-	/**
171
-	 * send server-to-server unshare to remote server
172
-	 *
173
-	 * @param string $remote url
174
-	 * @param int $id share id
175
-	 * @param string $token
176
-	 * @return bool
177
-	 */
178
-	public function sendRemoteUnShare($remote, $id, $token) {
179
-		$this->sendUpdateToRemote($remote, $id, $token, 'unshare');
180
-	}
181
-
182
-	/**
183
-	 * send server-to-server unshare to remote server
184
-	 *
185
-	 * @param string $remote url
186
-	 * @param int $id share id
187
-	 * @param string $token
188
-	 * @return bool
189
-	 */
190
-	public function sendRevokeShare($remote, $id, $token) {
191
-		$this->sendUpdateToRemote($remote, $id, $token, 'revoke');
192
-	}
193
-
194
-	/**
195
-	 * send notification to remote server if the permissions was changed
196
-	 *
197
-	 * @param string $remote
198
-	 * @param int $remoteId
199
-	 * @param string $token
200
-	 * @param int $permissions
201
-	 * @return bool
202
-	 */
203
-	public function sendPermissionChange($remote, $remoteId, $token, $permissions) {
204
-		$this->sendUpdateToRemote($remote, $remoteId, $token, 'permissions', ['permissions' => $permissions]);
205
-	}
206
-
207
-	/**
208
-	 * forward accept reShare to remote server
209
-	 *
210
-	 * @param string $remote
211
-	 * @param int $remoteId
212
-	 * @param string $token
213
-	 */
214
-	public function sendAcceptShare($remote, $remoteId, $token) {
215
-		$this->sendUpdateToRemote($remote, $remoteId, $token, 'accept');
216
-	}
217
-
218
-	/**
219
-	 * forward decline reShare to remote server
220
-	 *
221
-	 * @param string $remote
222
-	 * @param int $remoteId
223
-	 * @param string $token
224
-	 */
225
-	public function sendDeclineShare($remote, $remoteId, $token) {
226
-		$this->sendUpdateToRemote($remote, $remoteId, $token, 'decline');
227
-	}
228
-
229
-	/**
230
-	 * inform remote server whether server-to-server share was accepted/declined
231
-	 *
232
-	 * @param string $remote
233
-	 * @param string $token
234
-	 * @param int $remoteId Share id on the remote host
235
-	 * @param string $action possible actions: accept, decline, unshare, revoke, permissions
236
-	 * @param array $data
237
-	 * @param int $try
238
-	 * @return boolean
239
-	 */
240
-	public function sendUpdateToRemote($remote, $remoteId, $token, $action, $data = [], $try = 0) {
241
-
242
-		$fields = array('token' => $token);
243
-		foreach ($data as $key => $value) {
244
-			$fields[$key] = $value;
245
-		}
246
-
247
-		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $remoteId . '/' . $action, $fields);
248
-		$status = json_decode($result['result'], true);
249
-
250
-		if ($result['success'] &&
251
-			($status['ocs']['meta']['statuscode'] === 100 ||
252
-				$status['ocs']['meta']['statuscode'] === 200
253
-			)
254
-		) {
255
-			return true;
256
-		} elseif ($try === 0) {
257
-			// only add new job on first try
258
-			$this->jobList->add('OCA\FederatedFileSharing\BackgroundJob\RetryJob',
259
-				[
260
-					'remote' => $remote,
261
-					'remoteId' => $remoteId,
262
-					'token' => $token,
263
-					'action' => $action,
264
-					'data' => json_encode($data),
265
-					'try' => $try,
266
-					'lastRun' => $this->getTimestamp()
267
-				]
268
-			);
269
-		}
270
-
271
-		return false;
272
-	}
273
-
274
-
275
-	/**
276
-	 * return current timestamp
277
-	 *
278
-	 * @return int
279
-	 */
280
-	protected function getTimestamp() {
281
-		return time();
282
-	}
283
-
284
-	/**
285
-	 * try http post with the given protocol, if no protocol is given we pick
286
-	 * the secure one (https)
287
-	 *
288
-	 * @param string $remoteDomain
289
-	 * @param string $urlSuffix
290
-	 * @param array $fields post parameters
291
-	 * @param string $action define the action (possible values: share, reshare, accept, decline, unshare, revoke, permissions)
292
-	 * @return array
293
-	 * @throws \Exception
294
-	 */
295
-	protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $fields, $action="share") {
296
-
297
-		if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) {
298
-			$remoteDomain = 'https://' . $remoteDomain;
299
-		}
300
-
301
-		$result = [
302
-			'success' => false,
303
-			'result' => '',
304
-		];
305
-
306
-		// if possible we use the new OCM API
307
-		$ocmResult = $this->tryOCMEndPoint($remoteDomain, $fields, $action);
308
-		if ($ocmResult) {
309
-			$result['success'] = true;
310
-			return $result;
311
-		}
312
-
313
-		// Fall back to old API
314
-		$client = $this->httpClientService->newClient();
315
-		$federationEndpoints = $this->discoveryService->discover($remoteDomain, 'FEDERATED_SHARING');
316
-		$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
317
-		try {
318
-			$response = $client->post($remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, [
319
-				'body' => $fields,
320
-				'timeout' => 10,
321
-				'connect_timeout' => 10,
322
-			]);
323
-			$result['result'] = $response->getBody();
324
-			$result['success'] = true;
325
-		} catch (\Exception $e) {
326
-			// if flat re-sharing is not supported by the remote server
327
-			// we re-throw the exception and fall back to the old behaviour.
328
-			// (flat re-shares has been introduced in Nextcloud 9.1)
329
-			if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) {
330
-				throw $e;
331
-			}
332
-		}
333
-
334
-		return $result;
335
-	}
336
-
337
-	/**
338
-	 * check if server supports the new OCM api and ask for the correct end-point
339
-	 *
340
-	 * @param string $url
341
-	 * @return string
342
-	 */
343
-	protected function getOCMEndPoint($url) {
344
-		$client = $this->httpClientService->newClient();
345
-		try {
346
-			$response = $client->get($url, ['timeout' => 10, 'connect_timeout' => 10]);
347
-		} catch (\Exception $e) {
348
-			return '';
349
-		}
350
-
351
-		$result = $response->getBody();
352
-		$result = json_decode($result, true);
353
-
354
-		if (isset($result['end-point'])) {
355
-			return $result['end-point'];
356
-		}
357
-
358
-		return '';
359
-	}
360
-
361
-	/**
362
-	 * send action regarding federated sharing to the remote server using the OCM API
363
-	 *
364
-	 * @param $remoteDomain
365
-	 * @param $fields
366
-	 * @param $action
367
-	 *
368
-	 * @return bool
369
-	 */
370
-	protected function tryOCMEndPoint($remoteDomain, $fields, $action) {
371
-		switch ($action) {
372
-			case 'share':
373
-				$share = $this->cloudFederationFactory->getCloudFederationShare(
374
-					$fields['shareWith'] . '@' . $remoteDomain,
375
-					$fields['name'],
376
-					'',
377
-					$fields['remoteId'],
378
-					$fields['ownerFederatedId'],
379
-					$fields['owner'],
380
-					$fields['sharedByFederatedId'],
381
-					$fields['sharedBy'],
382
-					['name' => 'webdav', 'options' => ['access_token' => $fields['token'], 'permissions' => ['read', 'write', 'share']]],
383
-					'user',
384
-					'file'
385
-				);
386
-				return $this->federationProviderManager->sendShare($share);
387
-		}
388
-
389
-	}
36
+    const RESPONSE_FORMAT = 'json'; // default response format for ocs calls
37
+
38
+    /** @var AddressHandler */
39
+    private $addressHandler;
40
+
41
+    /** @var IClientService */
42
+    private $httpClientService;
43
+
44
+    /** @var IDiscoveryService */
45
+    private $discoveryService;
46
+
47
+    /** @var IJobList  */
48
+    private $jobList;
49
+
50
+    /** @var ICloudFederationProviderManager */
51
+    private $federationProviderManager;
52
+
53
+    /** @var ICloudFederationFactory */
54
+    private $cloudFederationFactory;
55
+
56
+    /**
57
+     * @param AddressHandler $addressHandler
58
+     * @param IClientService $httpClientService
59
+     * @param IDiscoveryService $discoveryService
60
+     * @param IJobList $jobList
61
+     * @param ICloudFederationProviderManager $federationProviderManager
62
+     * @param ICloudFederationFactory $cloudFederationFactory
63
+     */
64
+    public function __construct(
65
+        AddressHandler $addressHandler,
66
+        IClientService $httpClientService,
67
+        IDiscoveryService $discoveryService,
68
+        IJobList $jobList,
69
+        ICloudFederationProviderManager $federationProviderManager,
70
+        ICloudFederationFactory $cloudFederationFactory
71
+    ) {
72
+        $this->addressHandler = $addressHandler;
73
+        $this->httpClientService = $httpClientService;
74
+        $this->discoveryService = $discoveryService;
75
+        $this->jobList = $jobList;
76
+        $this->federationProviderManager = $federationProviderManager;
77
+        $this->cloudFederationFactory = $cloudFederationFactory;
78
+    }
79
+
80
+    /**
81
+     * send server-to-server share to remote server
82
+     *
83
+     * @param string $token
84
+     * @param string $shareWith
85
+     * @param string $name
86
+     * @param int $remote_id
87
+     * @param string $owner
88
+     * @param string $ownerFederatedId
89
+     * @param string $sharedBy
90
+     * @param string $sharedByFederatedId
91
+     * @return bool
92
+     * @throws \OC\HintException
93
+     * @throws \OC\ServerNotAvailableException
94
+     */
95
+    public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId) {
96
+
97
+        list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
98
+
99
+        if ($user && $remote) {
100
+            $local = $this->addressHandler->generateRemoteURL();
101
+
102
+            $fields = array(
103
+                'shareWith' => $user,
104
+                'token' => $token,
105
+                'name' => $name,
106
+                'remoteId' => $remote_id,
107
+                'owner' => $owner,
108
+                'ownerFederatedId' => $ownerFederatedId,
109
+                'sharedBy' => $sharedBy,
110
+                'sharedByFederatedId' => $sharedByFederatedId,
111
+                'remote' => $local,
112
+            );
113
+
114
+            $result = $this->tryHttpPostToShareEndpoint($remote, '', $fields);
115
+            $status = json_decode($result['result'], true);
116
+
117
+            $ocsStatus = isset($status['ocs']);
118
+            $ocsSuccess = $ocsStatus && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200);
119
+
120
+            if ($result['success'] && (!$ocsStatus ||$ocsSuccess)) {
121
+                \OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $remote]);
122
+                return true;
123
+            }
124
+
125
+        }
126
+
127
+        return false;
128
+    }
129
+
130
+    /**
131
+     * ask owner to re-share the file with the given user
132
+     *
133
+     * @param string $token
134
+     * @param int $id remote Id
135
+     * @param int $shareId internal share Id
136
+     * @param string $remote remote address of the owner
137
+     * @param string $shareWith
138
+     * @param int $permission
139
+     * @return bool
140
+     * @throws \OC\HintException
141
+     * @throws \OC\ServerNotAvailableException
142
+     */
143
+    public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission) {
144
+
145
+        $fields = array(
146
+            'shareWith' => $shareWith,
147
+            'token' => $token,
148
+            'permission' => $permission,
149
+            'remoteId' => $shareId
150
+        );
151
+
152
+        $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $id . '/reshare', $fields);
153
+        $status = json_decode($result['result'], true);
154
+
155
+        $httpRequestSuccessful = $result['success'];
156
+        $ocsCallSuccessful = $status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200;
157
+        $validToken = isset($status['ocs']['data']['token']) && is_string($status['ocs']['data']['token']);
158
+        $validRemoteId = isset($status['ocs']['data']['remoteId']);
159
+
160
+        if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) {
161
+            return [
162
+                $status['ocs']['data']['token'],
163
+                (int)$status['ocs']['data']['remoteId']
164
+            ];
165
+        }
166
+
167
+        return false;
168
+    }
169
+
170
+    /**
171
+     * send server-to-server unshare to remote server
172
+     *
173
+     * @param string $remote url
174
+     * @param int $id share id
175
+     * @param string $token
176
+     * @return bool
177
+     */
178
+    public function sendRemoteUnShare($remote, $id, $token) {
179
+        $this->sendUpdateToRemote($remote, $id, $token, 'unshare');
180
+    }
181
+
182
+    /**
183
+     * send server-to-server unshare to remote server
184
+     *
185
+     * @param string $remote url
186
+     * @param int $id share id
187
+     * @param string $token
188
+     * @return bool
189
+     */
190
+    public function sendRevokeShare($remote, $id, $token) {
191
+        $this->sendUpdateToRemote($remote, $id, $token, 'revoke');
192
+    }
193
+
194
+    /**
195
+     * send notification to remote server if the permissions was changed
196
+     *
197
+     * @param string $remote
198
+     * @param int $remoteId
199
+     * @param string $token
200
+     * @param int $permissions
201
+     * @return bool
202
+     */
203
+    public function sendPermissionChange($remote, $remoteId, $token, $permissions) {
204
+        $this->sendUpdateToRemote($remote, $remoteId, $token, 'permissions', ['permissions' => $permissions]);
205
+    }
206
+
207
+    /**
208
+     * forward accept reShare to remote server
209
+     *
210
+     * @param string $remote
211
+     * @param int $remoteId
212
+     * @param string $token
213
+     */
214
+    public function sendAcceptShare($remote, $remoteId, $token) {
215
+        $this->sendUpdateToRemote($remote, $remoteId, $token, 'accept');
216
+    }
217
+
218
+    /**
219
+     * forward decline reShare to remote server
220
+     *
221
+     * @param string $remote
222
+     * @param int $remoteId
223
+     * @param string $token
224
+     */
225
+    public function sendDeclineShare($remote, $remoteId, $token) {
226
+        $this->sendUpdateToRemote($remote, $remoteId, $token, 'decline');
227
+    }
228
+
229
+    /**
230
+     * inform remote server whether server-to-server share was accepted/declined
231
+     *
232
+     * @param string $remote
233
+     * @param string $token
234
+     * @param int $remoteId Share id on the remote host
235
+     * @param string $action possible actions: accept, decline, unshare, revoke, permissions
236
+     * @param array $data
237
+     * @param int $try
238
+     * @return boolean
239
+     */
240
+    public function sendUpdateToRemote($remote, $remoteId, $token, $action, $data = [], $try = 0) {
241
+
242
+        $fields = array('token' => $token);
243
+        foreach ($data as $key => $value) {
244
+            $fields[$key] = $value;
245
+        }
246
+
247
+        $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $remoteId . '/' . $action, $fields);
248
+        $status = json_decode($result['result'], true);
249
+
250
+        if ($result['success'] &&
251
+            ($status['ocs']['meta']['statuscode'] === 100 ||
252
+                $status['ocs']['meta']['statuscode'] === 200
253
+            )
254
+        ) {
255
+            return true;
256
+        } elseif ($try === 0) {
257
+            // only add new job on first try
258
+            $this->jobList->add('OCA\FederatedFileSharing\BackgroundJob\RetryJob',
259
+                [
260
+                    'remote' => $remote,
261
+                    'remoteId' => $remoteId,
262
+                    'token' => $token,
263
+                    'action' => $action,
264
+                    'data' => json_encode($data),
265
+                    'try' => $try,
266
+                    'lastRun' => $this->getTimestamp()
267
+                ]
268
+            );
269
+        }
270
+
271
+        return false;
272
+    }
273
+
274
+
275
+    /**
276
+     * return current timestamp
277
+     *
278
+     * @return int
279
+     */
280
+    protected function getTimestamp() {
281
+        return time();
282
+    }
283
+
284
+    /**
285
+     * try http post with the given protocol, if no protocol is given we pick
286
+     * the secure one (https)
287
+     *
288
+     * @param string $remoteDomain
289
+     * @param string $urlSuffix
290
+     * @param array $fields post parameters
291
+     * @param string $action define the action (possible values: share, reshare, accept, decline, unshare, revoke, permissions)
292
+     * @return array
293
+     * @throws \Exception
294
+     */
295
+    protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $fields, $action="share") {
296
+
297
+        if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) {
298
+            $remoteDomain = 'https://' . $remoteDomain;
299
+        }
300
+
301
+        $result = [
302
+            'success' => false,
303
+            'result' => '',
304
+        ];
305
+
306
+        // if possible we use the new OCM API
307
+        $ocmResult = $this->tryOCMEndPoint($remoteDomain, $fields, $action);
308
+        if ($ocmResult) {
309
+            $result['success'] = true;
310
+            return $result;
311
+        }
312
+
313
+        // Fall back to old API
314
+        $client = $this->httpClientService->newClient();
315
+        $federationEndpoints = $this->discoveryService->discover($remoteDomain, 'FEDERATED_SHARING');
316
+        $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
317
+        try {
318
+            $response = $client->post($remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, [
319
+                'body' => $fields,
320
+                'timeout' => 10,
321
+                'connect_timeout' => 10,
322
+            ]);
323
+            $result['result'] = $response->getBody();
324
+            $result['success'] = true;
325
+        } catch (\Exception $e) {
326
+            // if flat re-sharing is not supported by the remote server
327
+            // we re-throw the exception and fall back to the old behaviour.
328
+            // (flat re-shares has been introduced in Nextcloud 9.1)
329
+            if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) {
330
+                throw $e;
331
+            }
332
+        }
333
+
334
+        return $result;
335
+    }
336
+
337
+    /**
338
+     * check if server supports the new OCM api and ask for the correct end-point
339
+     *
340
+     * @param string $url
341
+     * @return string
342
+     */
343
+    protected function getOCMEndPoint($url) {
344
+        $client = $this->httpClientService->newClient();
345
+        try {
346
+            $response = $client->get($url, ['timeout' => 10, 'connect_timeout' => 10]);
347
+        } catch (\Exception $e) {
348
+            return '';
349
+        }
350
+
351
+        $result = $response->getBody();
352
+        $result = json_decode($result, true);
353
+
354
+        if (isset($result['end-point'])) {
355
+            return $result['end-point'];
356
+        }
357
+
358
+        return '';
359
+    }
360
+
361
+    /**
362
+     * send action regarding federated sharing to the remote server using the OCM API
363
+     *
364
+     * @param $remoteDomain
365
+     * @param $fields
366
+     * @param $action
367
+     *
368
+     * @return bool
369
+     */
370
+    protected function tryOCMEndPoint($remoteDomain, $fields, $action) {
371
+        switch ($action) {
372
+            case 'share':
373
+                $share = $this->cloudFederationFactory->getCloudFederationShare(
374
+                    $fields['shareWith'] . '@' . $remoteDomain,
375
+                    $fields['name'],
376
+                    '',
377
+                    $fields['remoteId'],
378
+                    $fields['ownerFederatedId'],
379
+                    $fields['owner'],
380
+                    $fields['sharedByFederatedId'],
381
+                    $fields['sharedBy'],
382
+                    ['name' => 'webdav', 'options' => ['access_token' => $fields['token'], 'permissions' => ['read', 'write', 'share']]],
383
+                    'user',
384
+                    'file'
385
+                );
386
+                return $this->federationProviderManager->sendShare($share);
387
+        }
388
+
389
+    }
390 390
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			$ocsStatus = isset($status['ocs']);
118 118
 			$ocsSuccess = $ocsStatus && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200);
119 119
 
120
-			if ($result['success'] && (!$ocsStatus ||$ocsSuccess)) {
120
+			if ($result['success'] && (!$ocsStatus || $ocsSuccess)) {
121 121
 				\OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $remote]);
122 122
 				return true;
123 123
 			}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 			'remoteId' => $shareId
150 150
 		);
151 151
 
152
-		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $id . '/reshare', $fields);
152
+		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/'.$id.'/reshare', $fields);
153 153
 		$status = json_decode($result['result'], true);
154 154
 
155 155
 		$httpRequestSuccessful = $result['success'];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) {
161 161
 			return [
162 162
 				$status['ocs']['data']['token'],
163
-				(int)$status['ocs']['data']['remoteId']
163
+				(int) $status['ocs']['data']['remoteId']
164 164
 			];
165 165
 		}
166 166
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 			$fields[$key] = $value;
245 245
 		}
246 246
 
247
-		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $remoteId . '/' . $action, $fields);
247
+		$result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/'.$remoteId.'/'.$action, $fields);
248 248
 		$status = json_decode($result['result'], true);
249 249
 
250 250
 		if ($result['success'] &&
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
 	 * @return array
293 293
 	 * @throws \Exception
294 294
 	 */
295
-	protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $fields, $action="share") {
295
+	protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $fields, $action = "share") {
296 296
 
297 297
 		if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) {
298
-			$remoteDomain = 'https://' . $remoteDomain;
298
+			$remoteDomain = 'https://'.$remoteDomain;
299 299
 		}
300 300
 
301 301
 		$result = [
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 		$federationEndpoints = $this->discoveryService->discover($remoteDomain, 'FEDERATED_SHARING');
316 316
 		$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
317 317
 		try {
318
-			$response = $client->post($remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, [
318
+			$response = $client->post($remoteDomain.$endpoint.$urlSuffix.'?format='.self::RESPONSE_FORMAT, [
319 319
 				'body' => $fields,
320 320
 				'timeout' => 10,
321 321
 				'connect_timeout' => 10,
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 		switch ($action) {
372 372
 			case 'share':
373 373
 				$share = $this->cloudFederationFactory->getCloudFederationShare(
374
-					$fields['shareWith'] . '@' . $remoteDomain,
374
+					$fields['shareWith'].'@'.$remoteDomain,
375 375
 					$fields['name'],
376 376
 					'',
377 377
 					$fields['remoteId'],
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -45,105 +45,105 @@
 block discarded – undo
45 45
  */
46 46
 class RetryJob extends Job {
47 47
 
48
-	/** @var  bool */
49
-	private $retainJob = true;
50
-
51
-	/** @var Notifications */
52
-	private $notifications;
53
-
54
-	/** @var int max number of attempts to send the request */
55
-	private $maxTry = 20;
56
-
57
-	/** @var int how much time should be between two tries (10 minutes) */
58
-	private $interval = 600;
59
-
60
-	/**
61
-	 * UnShare constructor.
62
-	 *
63
-	 * @param Notifications $notifications
64
-	 */
65
-	public function __construct(Notifications $notifications = null) {
66
-		if ($notifications) {
67
-			$this->notifications = $notifications;
68
-		} else {
69
-			$addressHandler = new AddressHandler(
70
-				\OC::$server->getURLGenerator(),
71
-				\OC::$server->getL10N('federatedfilesharing'),
72
-				\OC::$server->getCloudIdManager()
73
-			);
74
-			$this->notifications = new Notifications(
75
-				$addressHandler,
76
-				\OC::$server->getHTTPClientService(),
77
-				\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
78
-				\OC::$server->getJobList(),
79
-				\OC::$server->getCloudFederationProviderManager(),
80
-				\OC::$server->getCloudFederationFactory()
81
-			);
82
-		}
83
-
84
-	}
85
-
86
-	/**
87
-	 * run the job, then remove it from the jobList
88
-	 *
89
-	 * @param JobList $jobList
90
-	 * @param ILogger|null $logger
91
-	 */
92
-	public function execute($jobList, ILogger $logger = null) {
93
-
94
-		if ($this->shouldRun($this->argument)) {
95
-			parent::execute($jobList, $logger);
96
-			$jobList->remove($this, $this->argument);
97
-			if ($this->retainJob) {
98
-				$this->reAddJob($jobList, $this->argument);
99
-			}
100
-		}
101
-	}
102
-
103
-	protected function run($argument) {
104
-		$remote = $argument['remote'];
105
-		$remoteId = $argument['remoteId'];
106
-		$token = $argument['token'];
107
-		$action = $argument['action'];
108
-		$data = json_decode($argument['data'], true);
109
-		$try = (int)$argument['try'] + 1;
110
-
111
-		$result = $this->notifications->sendUpdateToRemote($remote, $remoteId, $token, $action, $data, $try);
112
-
113
-		if ($result === true || $try > $this->maxTry) {
114
-			$this->retainJob = false;
115
-		}
116
-	}
117
-
118
-	/**
119
-	 * re-add background job with new arguments
120
-	 *
121
-	 * @param IJobList $jobList
122
-	 * @param array $argument
123
-	 */
124
-	protected function reAddJob(IJobList $jobList, array $argument) {
125
-		$jobList->add(RetryJob::class,
126
-			[
127
-				'remote' => $argument['remote'],
128
-				'remoteId' => $argument['remoteId'],
129
-				'token' => $argument['token'],
130
-				'data' => $argument['data'],
131
-				'action' => $argument['action'],
132
-				'try' => (int)$argument['try'] + 1,
133
-				'lastRun' => time()
134
-			]
135
-		);
136
-	}
137
-
138
-	/**
139
-	 * test if it is time for the next run
140
-	 *
141
-	 * @param array $argument
142
-	 * @return bool
143
-	 */
144
-	protected function shouldRun(array $argument) {
145
-		$lastRun = (int)$argument['lastRun'];
146
-		return ((time() - $lastRun) > $this->interval);
147
-	}
48
+    /** @var  bool */
49
+    private $retainJob = true;
50
+
51
+    /** @var Notifications */
52
+    private $notifications;
53
+
54
+    /** @var int max number of attempts to send the request */
55
+    private $maxTry = 20;
56
+
57
+    /** @var int how much time should be between two tries (10 minutes) */
58
+    private $interval = 600;
59
+
60
+    /**
61
+     * UnShare constructor.
62
+     *
63
+     * @param Notifications $notifications
64
+     */
65
+    public function __construct(Notifications $notifications = null) {
66
+        if ($notifications) {
67
+            $this->notifications = $notifications;
68
+        } else {
69
+            $addressHandler = new AddressHandler(
70
+                \OC::$server->getURLGenerator(),
71
+                \OC::$server->getL10N('federatedfilesharing'),
72
+                \OC::$server->getCloudIdManager()
73
+            );
74
+            $this->notifications = new Notifications(
75
+                $addressHandler,
76
+                \OC::$server->getHTTPClientService(),
77
+                \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
78
+                \OC::$server->getJobList(),
79
+                \OC::$server->getCloudFederationProviderManager(),
80
+                \OC::$server->getCloudFederationFactory()
81
+            );
82
+        }
83
+
84
+    }
85
+
86
+    /**
87
+     * run the job, then remove it from the jobList
88
+     *
89
+     * @param JobList $jobList
90
+     * @param ILogger|null $logger
91
+     */
92
+    public function execute($jobList, ILogger $logger = null) {
93
+
94
+        if ($this->shouldRun($this->argument)) {
95
+            parent::execute($jobList, $logger);
96
+            $jobList->remove($this, $this->argument);
97
+            if ($this->retainJob) {
98
+                $this->reAddJob($jobList, $this->argument);
99
+            }
100
+        }
101
+    }
102
+
103
+    protected function run($argument) {
104
+        $remote = $argument['remote'];
105
+        $remoteId = $argument['remoteId'];
106
+        $token = $argument['token'];
107
+        $action = $argument['action'];
108
+        $data = json_decode($argument['data'], true);
109
+        $try = (int)$argument['try'] + 1;
110
+
111
+        $result = $this->notifications->sendUpdateToRemote($remote, $remoteId, $token, $action, $data, $try);
112
+
113
+        if ($result === true || $try > $this->maxTry) {
114
+            $this->retainJob = false;
115
+        }
116
+    }
117
+
118
+    /**
119
+     * re-add background job with new arguments
120
+     *
121
+     * @param IJobList $jobList
122
+     * @param array $argument
123
+     */
124
+    protected function reAddJob(IJobList $jobList, array $argument) {
125
+        $jobList->add(RetryJob::class,
126
+            [
127
+                'remote' => $argument['remote'],
128
+                'remoteId' => $argument['remoteId'],
129
+                'token' => $argument['token'],
130
+                'data' => $argument['data'],
131
+                'action' => $argument['action'],
132
+                'try' => (int)$argument['try'] + 1,
133
+                'lastRun' => time()
134
+            ]
135
+        );
136
+    }
137
+
138
+    /**
139
+     * test if it is time for the next run
140
+     *
141
+     * @param array $argument
142
+     * @return bool
143
+     */
144
+    protected function shouldRun(array $argument) {
145
+        $lastRun = (int)$argument['lastRun'];
146
+        return ((time() - $lastRun) > $this->interval);
147
+    }
148 148
 
149 149
 }
Please login to merge, or discard this patch.