Completed
Pull Request — master (#9345)
by Björn
57:07 queued 34:19
created
lib/public/Share/IShareProvider.php 1 patch
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -34,172 +34,172 @@
 block discarded – undo
34 34
  */
35 35
 interface IShareProvider {
36 36
 
37
-	/**
38
-	 * Return the identifier of this provider.
39
-	 *
40
-	 * @return string Containing only [a-zA-Z0-9]
41
-	 * @since 9.0.0
42
-	 */
43
-	public function identifier();
44
-
45
-	/**
46
-	 * Create a share
47
-	 *
48
-	 * @param \OCP\Share\IShare $share
49
-	 * @return \OCP\Share\IShare The share object
50
-	 * @since 9.0.0
51
-	 */
52
-	public function create(\OCP\Share\IShare $share);
53
-
54
-	/**
55
-	 * Update a share
56
-	 *
57
-	 * @param \OCP\Share\IShare $share
58
-	 * @return \OCP\Share\IShare The share object
59
-	 * @since 9.0.0
60
-	 */
61
-	public function update(\OCP\Share\IShare $share);
62
-
63
-	/**
64
-	 * Delete a share
65
-	 *
66
-	 * @param \OCP\Share\IShare $share
67
-	 * @since 9.0.0
68
-	 */
69
-	public function delete(\OCP\Share\IShare $share);
70
-
71
-	/**
72
-	 * Unshare a file from self as recipient.
73
-	 * This may require special handling. If a user unshares a group
74
-	 * share from their self then the original group share should still exist.
75
-	 *
76
-	 * @param \OCP\Share\IShare $share
77
-	 * @param string $recipient UserId of the recipient
78
-	 * @since 9.0.0
79
-	 */
80
-	public function deleteFromSelf(\OCP\Share\IShare $share, $recipient);
81
-
82
-	/**
83
-	 * Move a share as a recipient.
84
-	 * This is updating the share target. Thus the mount point of the recipient.
85
-	 * This may require special handling. If a user moves a group share
86
-	 * the target should only be changed for them.
87
-	 *
88
-	 * @param \OCP\Share\IShare $share
89
-	 * @param string $recipient userId of recipient
90
-	 * @return \OCP\Share\IShare
91
-	 * @since 9.0.0
92
-	 */
93
-	public function move(\OCP\Share\IShare $share, $recipient);
94
-
95
-	/**
96
-	 * Get all shares by the given user in a folder
97
-	 *
98
-	 * @param string $userId
99
-	 * @param Folder $node
100
-	 * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
101
-	 * @return \OCP\Share\IShare[]
102
-	 * @since 11.0.0
103
-	 */
104
-	public function getSharesInFolder($userId, Folder $node, $reshares);
105
-
106
-	/**
107
-	 * Get all shares by the given user
108
-	 *
109
-	 * @param string $userId
110
-	 * @param int $shareType
111
-	 * @param Node|null $node
112
-	 * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
113
-	 * @param int $limit The maximum number of shares to be returned, -1 for all shares
114
-	 * @param int $offset
115
-	 * @return \OCP\Share\IShare[]
116
-	 * @since 9.0.0
117
-	 */
118
-	public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset);
119
-
120
-	/**
121
-	 * Get share by id
122
-	 *
123
-	 * @param int $id
124
-	 * @param string|null $recipientId
125
-	 * @return \OCP\Share\IShare
126
-	 * @throws ShareNotFound
127
-	 * @since 9.0.0
128
-	 */
129
-	public function getShareById($id, $recipientId = null);
130
-
131
-	/**
132
-	 * Get shares for a given path
133
-	 *
134
-	 * @param Node $path
135
-	 * @return \OCP\Share\IShare[]
136
-	 * @since 9.0.0
137
-	 */
138
-	public function getSharesByPath(Node $path);
139
-
140
-	/**
141
-	 * Get shared with the given user
142
-	 *
143
-	 * @param string $userId get shares where this user is the recipient
144
-	 * @param int $shareType
145
-	 * @param Node|null $node
146
-	 * @param int $limit The max number of entries returned, -1 for all
147
-	 * @param int $offset
148
-	 * @return \OCP\Share\IShare[]
149
-	 * @since 9.0.0
150
-	 */
151
-	public function getSharedWith($userId, $shareType, $node, $limit, $offset);
152
-
153
-	/**
154
-	 * Get a share by token
155
-	 *
156
-	 * @param string $token
157
-	 * @return \OCP\Share\IShare
158
-	 * @throws ShareNotFound
159
-	 * @since 9.0.0
160
-	 */
161
-	public function getShareByToken($token);
162
-
163
-	/**
164
-	 * A user is deleted from the system
165
-	 * So clean up the relevant shares.
166
-	 *
167
-	 * @param string $uid
168
-	 * @param int $shareType
169
-	 * @since 9.1.0
170
-	 */
171
-	public function userDeleted($uid, $shareType);
172
-
173
-	/**
174
-	 * A group is deleted from the system.
175
-	 * We have to clean up all shares to this group.
176
-	 * Providers not handling group shares should just return
177
-	 *
178
-	 * @param string $gid
179
-	 * @since 9.1.0
180
-	 */
181
-	public function groupDeleted($gid);
182
-
183
-	/**
184
-	 * A user is deleted from a group
185
-	 * We have to clean up all the related user specific group shares
186
-	 * Providers not handling group shares should just return
187
-	 *
188
-	 * @param string $uid
189
-	 * @param string $gid
190
-	 * @since 9.1.0
191
-	 */
192
-	public function userDeletedFromGroup($uid, $gid);
193
-
194
-	/**
195
-	 * Get the access list to the array of provided nodes.
196
-	 *
197
-	 * @see IManager::getAccessList() for sample docs
198
-	 *
199
-	 * @param Node[] $nodes The list of nodes to get access for
200
-	 * @param bool $currentAccess If current access is required (like for removed shares that might get revived later)
201
-	 * @return array
202
-	 * @since 12
203
-	 */
204
-	public function getAccessList($nodes, $currentAccess);
37
+    /**
38
+     * Return the identifier of this provider.
39
+     *
40
+     * @return string Containing only [a-zA-Z0-9]
41
+     * @since 9.0.0
42
+     */
43
+    public function identifier();
44
+
45
+    /**
46
+     * Create a share
47
+     *
48
+     * @param \OCP\Share\IShare $share
49
+     * @return \OCP\Share\IShare The share object
50
+     * @since 9.0.0
51
+     */
52
+    public function create(\OCP\Share\IShare $share);
53
+
54
+    /**
55
+     * Update a share
56
+     *
57
+     * @param \OCP\Share\IShare $share
58
+     * @return \OCP\Share\IShare The share object
59
+     * @since 9.0.0
60
+     */
61
+    public function update(\OCP\Share\IShare $share);
62
+
63
+    /**
64
+     * Delete a share
65
+     *
66
+     * @param \OCP\Share\IShare $share
67
+     * @since 9.0.0
68
+     */
69
+    public function delete(\OCP\Share\IShare $share);
70
+
71
+    /**
72
+     * Unshare a file from self as recipient.
73
+     * This may require special handling. If a user unshares a group
74
+     * share from their self then the original group share should still exist.
75
+     *
76
+     * @param \OCP\Share\IShare $share
77
+     * @param string $recipient UserId of the recipient
78
+     * @since 9.0.0
79
+     */
80
+    public function deleteFromSelf(\OCP\Share\IShare $share, $recipient);
81
+
82
+    /**
83
+     * Move a share as a recipient.
84
+     * This is updating the share target. Thus the mount point of the recipient.
85
+     * This may require special handling. If a user moves a group share
86
+     * the target should only be changed for them.
87
+     *
88
+     * @param \OCP\Share\IShare $share
89
+     * @param string $recipient userId of recipient
90
+     * @return \OCP\Share\IShare
91
+     * @since 9.0.0
92
+     */
93
+    public function move(\OCP\Share\IShare $share, $recipient);
94
+
95
+    /**
96
+     * Get all shares by the given user in a folder
97
+     *
98
+     * @param string $userId
99
+     * @param Folder $node
100
+     * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
101
+     * @return \OCP\Share\IShare[]
102
+     * @since 11.0.0
103
+     */
104
+    public function getSharesInFolder($userId, Folder $node, $reshares);
105
+
106
+    /**
107
+     * Get all shares by the given user
108
+     *
109
+     * @param string $userId
110
+     * @param int $shareType
111
+     * @param Node|null $node
112
+     * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
113
+     * @param int $limit The maximum number of shares to be returned, -1 for all shares
114
+     * @param int $offset
115
+     * @return \OCP\Share\IShare[]
116
+     * @since 9.0.0
117
+     */
118
+    public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset);
119
+
120
+    /**
121
+     * Get share by id
122
+     *
123
+     * @param int $id
124
+     * @param string|null $recipientId
125
+     * @return \OCP\Share\IShare
126
+     * @throws ShareNotFound
127
+     * @since 9.0.0
128
+     */
129
+    public function getShareById($id, $recipientId = null);
130
+
131
+    /**
132
+     * Get shares for a given path
133
+     *
134
+     * @param Node $path
135
+     * @return \OCP\Share\IShare[]
136
+     * @since 9.0.0
137
+     */
138
+    public function getSharesByPath(Node $path);
139
+
140
+    /**
141
+     * Get shared with the given user
142
+     *
143
+     * @param string $userId get shares where this user is the recipient
144
+     * @param int $shareType
145
+     * @param Node|null $node
146
+     * @param int $limit The max number of entries returned, -1 for all
147
+     * @param int $offset
148
+     * @return \OCP\Share\IShare[]
149
+     * @since 9.0.0
150
+     */
151
+    public function getSharedWith($userId, $shareType, $node, $limit, $offset);
152
+
153
+    /**
154
+     * Get a share by token
155
+     *
156
+     * @param string $token
157
+     * @return \OCP\Share\IShare
158
+     * @throws ShareNotFound
159
+     * @since 9.0.0
160
+     */
161
+    public function getShareByToken($token);
162
+
163
+    /**
164
+     * A user is deleted from the system
165
+     * So clean up the relevant shares.
166
+     *
167
+     * @param string $uid
168
+     * @param int $shareType
169
+     * @since 9.1.0
170
+     */
171
+    public function userDeleted($uid, $shareType);
172
+
173
+    /**
174
+     * A group is deleted from the system.
175
+     * We have to clean up all shares to this group.
176
+     * Providers not handling group shares should just return
177
+     *
178
+     * @param string $gid
179
+     * @since 9.1.0
180
+     */
181
+    public function groupDeleted($gid);
182
+
183
+    /**
184
+     * A user is deleted from a group
185
+     * We have to clean up all the related user specific group shares
186
+     * Providers not handling group shares should just return
187
+     *
188
+     * @param string $uid
189
+     * @param string $gid
190
+     * @since 9.1.0
191
+     */
192
+    public function userDeletedFromGroup($uid, $gid);
193
+
194
+    /**
195
+     * Get the access list to the array of provided nodes.
196
+     *
197
+     * @see IManager::getAccessList() for sample docs
198
+     *
199
+     * @param Node[] $nodes The list of nodes to get access for
200
+     * @param bool $currentAccess If current access is required (like for removed shares that might get revived later)
201
+     * @return array
202
+     * @since 12
203
+     */
204
+    public function getAccessList($nodes, $currentAccess);
205 205
 }
Please login to merge, or discard this patch.
apps/federatedfilesharing/lib/ocm/CloudFederationProviderFiles.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
 	 * share received from another server
122 122
 	 *
123 123
 	 * @param ICloudFederationShare $share
124
-	 * @return string provider specific unique ID of the share
124
+	 * @return integer provider specific unique ID of the share
125 125
 	 *
126 126
 	 * @throws ProviderCouldNotAddShareException
127 127
 	 * @throws \OCP\AppFramework\QueryException
Please login to merge, or discard this patch.
Indentation   +712 added lines, -712 removed lines patch added patch discarded remove patch
@@ -50,718 +50,718 @@
 block discarded – undo
50 50
 
51 51
 class CloudFederationProviderFiles implements ICloudFederationProvider {
52 52
 
53
-	/** @var IAppManager */
54
-	private $appManager;
55
-
56
-	/** @var FederatedShareProvider */
57
-	private $federatedShareProvider;
58
-
59
-	/** @var AddressHandler */
60
-	private $addressHandler;
61
-
62
-	/** @var ILogger */
63
-	private $logger;
64
-
65
-	/** @var IUserManager */
66
-	private $userManager;
67
-
68
-	/** @var ICloudIdManager */
69
-	private $cloudIdManager;
70
-
71
-	/** @var IActivityManager */
72
-	private $activityManager;
73
-
74
-	/** @var INotificationManager */
75
-	private $notificationManager;
76
-
77
-	/** @var IURLGenerator */
78
-	private $urlGenerator;
79
-
80
-	/** @var ICloudFederationFactory */
81
-	private $cloudFederationFactory;
82
-
83
-	/** @var ICloudFederationProviderManager */
84
-	private $cloudFederationProviderManager;
85
-
86
-	/** @var IDBConnection */
87
-	private $connection;
88
-
89
-	/**
90
-	 * CloudFederationProvider constructor.
91
-	 *
92
-	 * @param IAppManager $appManager
93
-	 * @param FederatedShareProvider $federatedShareProvider
94
-	 * @param AddressHandler $addressHandler
95
-	 * @param ILogger $logger
96
-	 * @param IUserManager $userManager
97
-	 * @param ICloudIdManager $cloudIdManager
98
-	 * @param IActivityManager $activityManager
99
-	 * @param INotificationManager $notificationManager
100
-	 * @param IURLGenerator $urlGenerator
101
-	 * @param ICloudFederationFactory $cloudFederationFactory
102
-	 * @param ICloudFederationProviderManager $cloudFederationProviderManager
103
-	 * @param IDBConnection $connection
104
-	 */
105
-	public function __construct(IAppManager $appManager,
106
-								FederatedShareProvider $federatedShareProvider,
107
-								AddressHandler $addressHandler,
108
-								ILogger $logger,
109
-								IUserManager $userManager,
110
-								ICloudIdManager $cloudIdManager,
111
-								IActivityManager $activityManager,
112
-								INotificationManager $notificationManager,
113
-								IURLGenerator $urlGenerator,
114
-								ICloudFederationFactory $cloudFederationFactory,
115
-								ICloudFederationProviderManager $cloudFederationProviderManager,
116
-								IDBConnection $connection
117
-	) {
118
-		$this->appManager = $appManager;
119
-		$this->federatedShareProvider = $federatedShareProvider;
120
-		$this->addressHandler = $addressHandler;
121
-		$this->logger = $logger;
122
-		$this->userManager = $userManager;
123
-		$this->cloudIdManager = $cloudIdManager;
124
-		$this->activityManager = $activityManager;
125
-		$this->notificationManager = $notificationManager;
126
-		$this->urlGenerator = $urlGenerator;
127
-		$this->cloudFederationFactory = $cloudFederationFactory;
128
-		$this->cloudFederationProviderManager = $cloudFederationProviderManager;
129
-		$this->connection = $connection;
130
-	}
131
-
132
-
133
-
134
-	/**
135
-	 * @return string
136
-	 */
137
-	public function getShareType() {
138
-		return 'file';
139
-	}
140
-
141
-	/**
142
-	 * share received from another server
143
-	 *
144
-	 * @param ICloudFederationShare $share
145
-	 * @return string provider specific unique ID of the share
146
-	 *
147
-	 * @throws ProviderCouldNotAddShareException
148
-	 * @throws \OCP\AppFramework\QueryException
149
-	 * @throws \OC\HintException
150
-	 * @since 14.0.0
151
-	 */
152
-	public function shareReceived(ICloudFederationShare $share) {
153
-
154
-		if (!$this->isS2SEnabled(true)) {
155
-			throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE);
156
-		}
157
-
158
-		$protocol = $share->getProtocol();
159
-		if ($protocol['name'] !== 'webdav') {
160
-			throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED);
161
-		}
162
-
163
-		list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner());
164
-		// for backward compatibility make sure that the remote url stored in the
165
-		// database ends with a trailing slash
166
-		if (substr($remote, -1) !== '/') {
167
-			$remote = $remote . '/';
168
-		}
169
-
170
-		$token = $share->getShareSecret();
171
-		$name = $share->getResourceName();
172
-		$owner = $share->getOwnerDisplayName();
173
-		$sharedBy = $share->getSharedByDisplayName();
174
-		$shareWith = $share->getShareWith();
175
-		$remoteId = $share->getProviderId();
176
-		$sharedByFederatedId = $share->getSharedBy();
177
-		$ownerFederatedId = $share->getOwner();
178
-
179
-		// if no explicit information about the person who created the share was send
180
-		// we assume that the share comes from the owner
181
-		if ($sharedByFederatedId === null) {
182
-			$sharedBy = $owner;
183
-			$sharedByFederatedId = $ownerFederatedId;
184
-		}
185
-
186
-		if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
187
-
188
-			if (!Util::isValidFileName($name)) {
189
-				throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST);
190
-			}
191
-
192
-			// FIXME this should be a method in the user management instead
193
-			$this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']);
194
-			Util::emitHook(
195
-				'\OCA\Files_Sharing\API\Server2Server',
196
-				'preLoginNameUsedAsUserName',
197
-				array('uid' => &$shareWith)
198
-			);
199
-			$this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']);
200
-
201
-			if (!$this->userManager->userExists($shareWith)) {
202
-				throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST);
203
-			}
204
-
205
-			\OC_Util::setupFS($shareWith);
206
-
207
-			$externalManager = new \OCA\Files_Sharing\External\Manager(
208
-				\OC::$server->getDatabaseConnection(),
209
-				Filesystem::getMountManager(),
210
-				Filesystem::getLoader(),
211
-				\OC::$server->getHTTPClientService(),
212
-				\OC::$server->getNotificationManager(),
213
-				\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
214
-				\OC::$server->getCloudFederationProviderManager(),
215
-				\OC::$server->getCloudFederationFactory(),
216
-				$shareWith
217
-			);
218
-
219
-			try {
220
-				$externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId);
221
-				$shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');
222
-
223
-				$event = $this->activityManager->generateEvent();
224
-				$event->setApp('files_sharing')
225
-					->setType('remote_share')
226
-					->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')])
227
-					->setAffectedUser($shareWith)
228
-					->setObject('remote_share', (int)$shareId, $name);
229
-				\OC::$server->getActivityManager()->publish($event);
230
-
231
-				$notification = $this->notificationManager->createNotification();
232
-				$notification->setApp('files_sharing')
233
-					->setUser($shareWith)
234
-					->setDateTime(new \DateTime())
235
-					->setObject('remote_share', $shareId)
236
-					->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]);
237
-
238
-				$declineAction = $notification->createAction();
239
-				$declineAction->setLabel('decline')
240
-					->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE');
241
-				$notification->addAction($declineAction);
242
-
243
-				$acceptAction = $notification->createAction();
244
-				$acceptAction->setLabel('accept')
245
-					->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST');
246
-				$notification->addAction($acceptAction);
247
-
248
-				$this->notificationManager->notify($notification);
249
-
250
-				return $shareId;
251
-			} catch (\Exception $e) {
252
-				$this->logger->logException($e, [
253
-					'message' => 'Server can not add remote share.',
254
-					'level' => ILogger::ERROR,
255
-					'app' => 'files_sharing'
256
-				]);
257
-				throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR);
258
-			}
259
-		}
260
-
261
-		throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST);
262
-
263
-	}
264
-
265
-	/**
266
-	 * notification received from another server
267
-	 *
268
-	 * @param string $notificationType (e.g. SHARE_ACCEPTED)
269
-	 * @param string $providerId id of the share
270
-	 * @param array $notification payload of the notification
271
-	 * @return array data send back to the sender
272
-	 *
273
-	 * @throws ActionNotSupportedException
274
-	 * @throws AuthenticationFailedException
275
-	 * @throws BadRequestException
276
-	 * @throws \OC\HintException
277
-	 * @since 14.0.0
278
-	 */
279
-	public function notificationReceived($notificationType, $providerId, array $notification) {
280
-
281
-		switch ($notificationType) {
282
-			case 'SHARE_ACCEPTED':
283
-				return $this->shareAccepted($providerId, $notification);
284
-			case 'SHARE_DECLINED':
285
-				return $this->shareDeclined($providerId, $notification);
286
-			case 'SHARE_UNSHARED':
287
-				return $this->unshare($providerId, $notification);
288
-			case 'REQUEST_RESHARE':
289
-				return $this->reshareRequested($providerId, $notification);
290
-			case 'RESHARE_UNDO':
291
-				return $this->undoReshare($providerId, $notification);
292
-			case 'RESHARE_CHANGE_PERMISSION':
293
-				return $this->updateResharePermissions($providerId, $notification);
294
-		}
295
-
296
-
297
-		throw new BadRequestException([$notificationType]);
298
-	}
299
-
300
-	/**
301
-	 * process notification that the recipient accepted a share
302
-	 *
303
-	 * @param string $id
304
-	 * @param array $notification
305
-	 * @return array
306
-	 * @throws ActionNotSupportedException
307
-	 * @throws AuthenticationFailedException
308
-	 * @throws BadRequestException
309
-	 * @throws \OC\HintException
310
-	 */
311
-	private function shareAccepted($id, array $notification) {
312
-
313
-		if (!$this->isS2SEnabled()) {
314
-			throw new ActionNotSupportedException('Server does not support federated cloud sharing');
315
-		}
316
-
317
-		if (!isset($notification['sharedSecret'])) {
318
-			throw new BadRequestException(['sharedSecret']);
319
-		}
320
-
321
-		$token = $notification['sharedSecret'];
322
-
323
-		$share = $this->federatedShareProvider->getShareById($id);
324
-
325
-		$this->verifyShare($share, $token);
326
-		$this->executeAcceptShare($share);
327
-		if ($share->getShareOwner() !== $share->getSharedBy()) {
328
-			list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
329
-			$remoteId = $this->federatedShareProvider->getRemoteId($share);
330
-			$notification = $this->cloudFederationFactory->getCloudFederationNotification();
331
-			$notification->setMessage(
332
-				'SHARE_ACCEPTED',
333
-				'file',
334
-				$remoteId,
335
-				[
336
-					'sharedSecret' => $token,
337
-					'message' => 'Recipient accepted the re-share'
338
-				]
339
-
340
-			);
341
-			$this->cloudFederationProviderManager->sendNotification($remote, $notification);
342
-
343
-		}
344
-
345
-		return [];
346
-	}
347
-
348
-	/**
349
-	 * @param IShare $share
350
-	 * @throws ShareNotFound
351
-	 */
352
-	protected function executeAcceptShare(IShare $share) {
353
-		try {
354
-			$fileId = (int)$share->getNode()->getId();
355
-			list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
356
-		} catch (\Exception $e) {
357
-			throw new ShareNotFound();
358
-		}
359
-
360
-		$event = $this->activityManager->generateEvent();
361
-		$event->setApp('files_sharing')
362
-			->setType('remote_share')
363
-			->setAffectedUser($this->getCorrectUid($share))
364
-			->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]])
365
-			->setObject('files', $fileId, $file)
366
-			->setLink($link);
367
-		$this->activityManager->publish($event);
368
-	}
369
-
370
-	/**
371
-	 * process notification that the recipient declined a share
372
-	 *
373
-	 * @param string $id
374
-	 * @param array $notification
375
-	 * @return array
376
-	 * @throws ActionNotSupportedException
377
-	 * @throws AuthenticationFailedException
378
-	 * @throws BadRequestException
379
-	 * @throws ShareNotFound
380
-	 * @throws \OC\HintException
381
-	 *
382
-	 */
383
-	protected function shareDeclined($id, array $notification) {
384
-
385
-		if (!$this->isS2SEnabled()) {
386
-			throw new ActionNotSupportedException('Server does not support federated cloud sharing');
387
-		}
388
-
389
-		if (!isset($notification['sharedSecret'])) {
390
-			throw new BadRequestException(['sharedSecret']);
391
-		}
392
-
393
-		$token = $notification['sharedSecret'];
394
-
395
-		$share = $this->federatedShareProvider->getShareById($id);
396
-
397
-		$this->verifyShare($share, $token);
398
-
399
-		if ($share->getShareOwner() !== $share->getSharedBy()) {
400
-			list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
401
-			$remoteId = $this->federatedShareProvider->getRemoteId($share);
402
-			$notification = $this->cloudFederationFactory->getCloudFederationNotification();
403
-			$notification->setMessage(
404
-				'SHARE_DECLINED',
405
-				'file',
406
-				$remoteId,
407
-				[
408
-					'sharedSecret' => $token,
409
-					'message' => 'Recipient declined the re-share'
410
-				]
411
-
412
-			);
413
-			$this->cloudFederationProviderManager->sendNotification($remote, $notification);
414
-		}
415
-
416
-		$this->executeDeclineShare($share);
417
-
418
-		return [];
419
-
420
-	}
421
-
422
-	/**
423
-	 * delete declined share and create a activity
424
-	 *
425
-	 * @param IShare $share
426
-	 * @throws ShareNotFound
427
-	 */
428
-	protected function executeDeclineShare(IShare $share) {
429
-		$this->federatedShareProvider->removeShareFromTable($share);
430
-
431
-		try {
432
-			$fileId = (int)$share->getNode()->getId();
433
-			list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
434
-		} catch (\Exception $e) {
435
-			throw new ShareNotFound();
436
-		}
437
-
438
-		$event = $this->activityManager->generateEvent();
439
-		$event->setApp('files_sharing')
440
-			->setType('remote_share')
441
-			->setAffectedUser($this->getCorrectUid($share))
442
-			->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]])
443
-			->setObject('files', $fileId, $file)
444
-			->setLink($link);
445
-		$this->activityManager->publish($event);
446
-
447
-	}
448
-
449
-	/**
450
-	 * received the notification that the owner unshared a file from you
451
-	 *
452
-	 * @param string $id
453
-	 * @param array $notification
454
-	 * @return array
455
-	 * @throws AuthenticationFailedException
456
-	 * @throws BadRequestException
457
-	 */
458
-	private function undoReshare($id, array $notification) {
459
-		if (!isset($notification['sharedSecret'])) {
460
-			throw new BadRequestException(['sharedSecret']);
461
-		}
462
-		$token = $notification['sharedSecret'];
463
-
464
-		$share = $this->federatedShareProvider->getShareById($id);
465
-
466
-		$this->verifyShare($share, $token);
467
-		$this->federatedShareProvider->removeShareFromTable($share);
468
-		return [];
469
-	}
470
-
471
-	/**
472
-	 * unshare file from self
473
-	 *
474
-	 * @param string $id
475
-	 * @param array $notification
476
-	 * @return array
477
-	 * @throws ActionNotSupportedException
478
-	 * @throws BadRequestException
479
-	 */
480
-	private function unshare($id, array $notification) {
481
-
482
-		if (!$this->isS2SEnabled(true)) {
483
-			throw new ActionNotSupportedException("incoming shares disabled!");
484
-		}
485
-
486
-		if (!isset($notification['sharedSecret'])) {
487
-			throw new BadRequestException(['sharedSecret']);
488
-		}
489
-		$token = $notification['sharedSecret'];
490
-
491
-		$qb = $this->connection->getQueryBuilder();
492
-		$qb->select('*')
493
-			->from('share_external')
494
-			->where(
495
-				$qb->expr()->andX(
496
-					$qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
497
-					$qb->expr()->eq('share_token', $qb->createNamedParameter($token))
498
-				)
499
-			);
500
-
501
-		$result = $qb->execute();
502
-		$share = $result->fetch();
503
-		$result->closeCursor();
504
-
505
-		if ($token && $id && !empty($share)) {
506
-
507
-			$remote = $this->cleanupRemote($share['remote']);
508
-
509
-			$owner = $this->cloudIdManager->getCloudId($share['owner'], $remote);
510
-			$mountpoint = $share['mountpoint'];
511
-			$user = $share['user'];
512
-
513
-			$qb = $this->connection->getQueryBuilder();
514
-			$qb->delete('share_external')
515
-				->where(
516
-					$qb->expr()->andX(
517
-						$qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
518
-						$qb->expr()->eq('share_token', $qb->createNamedParameter($token))
519
-					)
520
-				);
521
-
522
-			$qb->execute();
523
-
524
-			if ($share['accepted']) {
525
-				$path = trim($mountpoint, '/');
526
-			} else {
527
-				$path = trim($share['name'], '/');
528
-			}
529
-
530
-			$notification = $this->notificationManager->createNotification();
531
-			$notification->setApp('files_sharing')
532
-				->setUser($share['user'])
533
-				->setObject('remote_share', (int)$share['id']);
534
-			$this->notificationManager->markProcessed($notification);
535
-
536
-			$event = $this->activityManager->generateEvent();
537
-			$event->setApp('files_sharing')
538
-				->setType('remote_share')
539
-				->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path])
540
-				->setAffectedUser($user)
541
-				->setObject('remote_share', (int)$share['id'], $path);
542
-			\OC::$server->getActivityManager()->publish($event);
543
-		}
544
-
545
-		return [];
546
-	}
547
-
548
-	private function cleanupRemote($remote) {
549
-		$remote = substr($remote, strpos($remote, '://') + 3);
550
-
551
-		return rtrim($remote, '/');
552
-	}
553
-
554
-	/**
555
-	 * recipient of a share request to re-share the file with another user
556
-	 *
557
-	 * @param string $id
558
-	 * @param array $notification
559
-	 * @return array
560
-	 * @throws AuthenticationFailedException
561
-	 * @throws BadRequestException
562
-	 * @throws ProviderCouldNotAddShareException
563
-	 * @throws ShareNotFound
564
-	 */
565
-	protected function reshareRequested($id, array $notification) {
566
-
567
-		if (!isset($notification['sharedSecret'])) {
568
-			throw new BadRequestException(['sharedSecret']);
569
-		}
570
-		$token = $notification['sharedSecret'];
571
-
572
-		if (!isset($notification['shareWith'])) {
573
-			throw new BadRequestException(['shareWith']);
574
-		}
575
-		$shareWith = $notification['shareWith'];
576
-
577
-		if (!isset($notification['senderId'])) {
578
-			throw new BadRequestException(['senderId']);
579
-		}
580
-		$senderId = $notification['senderId'];
581
-
582
-		$share = $this->federatedShareProvider->getShareById($id);
583
-		// don't allow to share a file back to the owner
584
-		try {
585
-			list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
586
-			$owner = $share->getShareOwner();
587
-			$currentServer = $this->addressHandler->generateRemoteURL();
588
-			if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) {
589
-				throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id);
590
-			}
591
-		} catch (\Exception $e) {
592
-			throw new ProviderCouldNotAddShareException($e->getMessage());
593
-		}
594
-
595
-		$this->verifyShare($share, $token);
596
-
597
-		// check if re-sharing is allowed
598
-		if ($share->getPermissions() & Constants::PERMISSION_SHARE) {
599
-			// the recipient of the initial share is now the initiator for the re-share
600
-			$share->setSharedBy($share->getSharedWith());
601
-			$share->setSharedWith($shareWith);
602
-			$result = $this->federatedShareProvider->create($share);
603
-			$this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId);
604
-			return ['token' => $result->getToken(), 'providerId' => $result->getId()];
605
-		} else {
606
-			throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id);
607
-		}
608
-
609
-	}
610
-
611
-	/**
612
-	 * update permission of a re-share so that the share dialog shows the right
613
-	 * permission if the owner or the sender changes the permission
614
-	 *
615
-	 * @param string $id
616
-	 * @param array $notification
617
-	 * @return array
618
-	 * @throws AuthenticationFailedException
619
-	 * @throws BadRequestException
620
-	 */
621
-	protected function updateResharePermissions($id, array $notification) {
622
-
623
-		if (!isset($notification['sharedSecret'])) {
624
-			throw new BadRequestException(['sharedSecret']);
625
-		}
626
-		$token = $notification['sharedSecret'];
627
-
628
-		if (!isset($notification['permission'])) {
629
-			throw new BadRequestException(['permission']);
630
-		}
631
-		$ocmPermissions = $notification['permission'];
632
-
633
-		$share = $this->federatedShareProvider->getShareById($id);
634
-
635
-		$ncPermission = $this->ocmPermissions2ncPermissions($ocmPermissions);
636
-
637
-		$this->verifyShare($share, $token);
638
-		$this->updatePermissionsInDatabase($share, $ncPermission);
639
-
640
-		return [];
641
-	}
642
-
643
-	/**
644
-	 * translate OCM Permissions to Nextcloud permissions
645
-	 *
646
-	 * @param array $ocmPermissions
647
-	 * @return int
648
-	 * @throws BadRequestException
649
-	 */
650
-	protected function ocmPermissions2ncPermissions(array $ocmPermissions) {
651
-		$ncPermissions = 0;
652
-		foreach($ocmPermissions as $permission) {
653
-			switch (strtolower($permission)) {
654
-				case 'read':
655
-					$ncPermissions += Constants::PERMISSION_READ;
656
-					break;
657
-				case 'write':
658
-					$ncPermissions += Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE;
659
-					break;
660
-				case 'share':
661
-					$ncPermissions += Constants::PERMISSION_SHARE;
662
-					break;
663
-				default:
664
-					throw new BadRequestException(['permission']);
665
-			}
666
-
667
-			error_log("new permissions: " . $ncPermissions);
668
-		}
669
-
670
-		return $ncPermissions;
671
-	}
672
-
673
-	/**
674
-	 * update permissions in database
675
-	 *
676
-	 * @param IShare $share
677
-	 * @param int $permissions
678
-	 */
679
-	protected function updatePermissionsInDatabase(IShare $share, $permissions) {
680
-		$query = $this->connection->getQueryBuilder();
681
-		$query->update('share')
682
-			->where($query->expr()->eq('id', $query->createNamedParameter($share->getId())))
683
-			->set('permissions', $query->createNamedParameter($permissions))
684
-			->execute();
685
-	}
686
-
687
-
688
-	/**
689
-	 * get file
690
-	 *
691
-	 * @param string $user
692
-	 * @param int $fileSource
693
-	 * @return array with internal path of the file and a absolute link to it
694
-	 */
695
-	private function getFile($user, $fileSource) {
696
-		\OC_Util::setupFS($user);
697
-
698
-		try {
699
-			$file = Filesystem::getPath($fileSource);
700
-		} catch (NotFoundException $e) {
701
-			$file = null;
702
-		}
703
-		$args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file);
704
-		$link = Util::linkToAbsolute('files', 'index.php', $args);
705
-
706
-		return [$file, $link];
707
-
708
-	}
709
-
710
-	/**
711
-	 * check if we are the initiator or the owner of a re-share and return the correct UID
712
-	 *
713
-	 * @param IShare $share
714
-	 * @return string
715
-	 */
716
-	protected function getCorrectUid(IShare $share) {
717
-		if ($this->userManager->userExists($share->getShareOwner())) {
718
-			return $share->getShareOwner();
719
-		}
720
-
721
-		return $share->getSharedBy();
722
-	}
723
-
724
-
725
-
726
-	/**
727
-	 * check if we got the right share
728
-	 *
729
-	 * @param IShare $share
730
-	 * @param string $token
731
-	 * @return bool
732
-	 * @throws AuthenticationFailedException
733
-	 */
734
-	protected function verifyShare(IShare $share, $token) {
735
-		if (
736
-			$share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE &&
737
-			$share->getToken() === $token
738
-		) {
739
-			return true;
740
-		}
741
-
742
-		throw new AuthenticationFailedException();
743
-	}
744
-
745
-
746
-
747
-	/**
748
-	 * check if server-to-server sharing is enabled
749
-	 *
750
-	 * @param bool $incoming
751
-	 * @return bool
752
-	 */
753
-	private function isS2SEnabled($incoming = false) {
754
-
755
-		$result = $this->appManager->isEnabledForUser('files_sharing');
756
-
757
-		if ($incoming) {
758
-			$result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();
759
-		} else {
760
-			$result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
761
-		}
762
-
763
-		return $result;
764
-	}
53
+    /** @var IAppManager */
54
+    private $appManager;
55
+
56
+    /** @var FederatedShareProvider */
57
+    private $federatedShareProvider;
58
+
59
+    /** @var AddressHandler */
60
+    private $addressHandler;
61
+
62
+    /** @var ILogger */
63
+    private $logger;
64
+
65
+    /** @var IUserManager */
66
+    private $userManager;
67
+
68
+    /** @var ICloudIdManager */
69
+    private $cloudIdManager;
70
+
71
+    /** @var IActivityManager */
72
+    private $activityManager;
73
+
74
+    /** @var INotificationManager */
75
+    private $notificationManager;
76
+
77
+    /** @var IURLGenerator */
78
+    private $urlGenerator;
79
+
80
+    /** @var ICloudFederationFactory */
81
+    private $cloudFederationFactory;
82
+
83
+    /** @var ICloudFederationProviderManager */
84
+    private $cloudFederationProviderManager;
85
+
86
+    /** @var IDBConnection */
87
+    private $connection;
88
+
89
+    /**
90
+     * CloudFederationProvider constructor.
91
+     *
92
+     * @param IAppManager $appManager
93
+     * @param FederatedShareProvider $federatedShareProvider
94
+     * @param AddressHandler $addressHandler
95
+     * @param ILogger $logger
96
+     * @param IUserManager $userManager
97
+     * @param ICloudIdManager $cloudIdManager
98
+     * @param IActivityManager $activityManager
99
+     * @param INotificationManager $notificationManager
100
+     * @param IURLGenerator $urlGenerator
101
+     * @param ICloudFederationFactory $cloudFederationFactory
102
+     * @param ICloudFederationProviderManager $cloudFederationProviderManager
103
+     * @param IDBConnection $connection
104
+     */
105
+    public function __construct(IAppManager $appManager,
106
+                                FederatedShareProvider $federatedShareProvider,
107
+                                AddressHandler $addressHandler,
108
+                                ILogger $logger,
109
+                                IUserManager $userManager,
110
+                                ICloudIdManager $cloudIdManager,
111
+                                IActivityManager $activityManager,
112
+                                INotificationManager $notificationManager,
113
+                                IURLGenerator $urlGenerator,
114
+                                ICloudFederationFactory $cloudFederationFactory,
115
+                                ICloudFederationProviderManager $cloudFederationProviderManager,
116
+                                IDBConnection $connection
117
+    ) {
118
+        $this->appManager = $appManager;
119
+        $this->federatedShareProvider = $federatedShareProvider;
120
+        $this->addressHandler = $addressHandler;
121
+        $this->logger = $logger;
122
+        $this->userManager = $userManager;
123
+        $this->cloudIdManager = $cloudIdManager;
124
+        $this->activityManager = $activityManager;
125
+        $this->notificationManager = $notificationManager;
126
+        $this->urlGenerator = $urlGenerator;
127
+        $this->cloudFederationFactory = $cloudFederationFactory;
128
+        $this->cloudFederationProviderManager = $cloudFederationProviderManager;
129
+        $this->connection = $connection;
130
+    }
131
+
132
+
133
+
134
+    /**
135
+     * @return string
136
+     */
137
+    public function getShareType() {
138
+        return 'file';
139
+    }
140
+
141
+    /**
142
+     * share received from another server
143
+     *
144
+     * @param ICloudFederationShare $share
145
+     * @return string provider specific unique ID of the share
146
+     *
147
+     * @throws ProviderCouldNotAddShareException
148
+     * @throws \OCP\AppFramework\QueryException
149
+     * @throws \OC\HintException
150
+     * @since 14.0.0
151
+     */
152
+    public function shareReceived(ICloudFederationShare $share) {
153
+
154
+        if (!$this->isS2SEnabled(true)) {
155
+            throw new ProviderCouldNotAddShareException('Server does not support federated cloud sharing', '', Http::STATUS_SERVICE_UNAVAILABLE);
156
+        }
157
+
158
+        $protocol = $share->getProtocol();
159
+        if ($protocol['name'] !== 'webdav') {
160
+            throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED);
161
+        }
162
+
163
+        list($ownerUid, $remote) = $this->addressHandler->splitUserRemote($share->getOwner());
164
+        // for backward compatibility make sure that the remote url stored in the
165
+        // database ends with a trailing slash
166
+        if (substr($remote, -1) !== '/') {
167
+            $remote = $remote . '/';
168
+        }
169
+
170
+        $token = $share->getShareSecret();
171
+        $name = $share->getResourceName();
172
+        $owner = $share->getOwnerDisplayName();
173
+        $sharedBy = $share->getSharedByDisplayName();
174
+        $shareWith = $share->getShareWith();
175
+        $remoteId = $share->getProviderId();
176
+        $sharedByFederatedId = $share->getSharedBy();
177
+        $ownerFederatedId = $share->getOwner();
178
+
179
+        // if no explicit information about the person who created the share was send
180
+        // we assume that the share comes from the owner
181
+        if ($sharedByFederatedId === null) {
182
+            $sharedBy = $owner;
183
+            $sharedByFederatedId = $ownerFederatedId;
184
+        }
185
+
186
+        if ($remote && $token && $name && $owner && $remoteId && $shareWith) {
187
+
188
+            if (!Util::isValidFileName($name)) {
189
+                throw new ProviderCouldNotAddShareException('The mountpoint name contains invalid characters.', '', Http::STATUS_BAD_REQUEST);
190
+            }
191
+
192
+            // FIXME this should be a method in the user management instead
193
+            $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']);
194
+            Util::emitHook(
195
+                '\OCA\Files_Sharing\API\Server2Server',
196
+                'preLoginNameUsedAsUserName',
197
+                array('uid' => &$shareWith)
198
+            );
199
+            $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']);
200
+
201
+            if (!$this->userManager->userExists($shareWith)) {
202
+                throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST);
203
+            }
204
+
205
+            \OC_Util::setupFS($shareWith);
206
+
207
+            $externalManager = new \OCA\Files_Sharing\External\Manager(
208
+                \OC::$server->getDatabaseConnection(),
209
+                Filesystem::getMountManager(),
210
+                Filesystem::getLoader(),
211
+                \OC::$server->getHTTPClientService(),
212
+                \OC::$server->getNotificationManager(),
213
+                \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
214
+                \OC::$server->getCloudFederationProviderManager(),
215
+                \OC::$server->getCloudFederationFactory(),
216
+                $shareWith
217
+            );
218
+
219
+            try {
220
+                $externalManager->addShare($remote, $token, '', $name, $owner, false, $shareWith, $remoteId);
221
+                $shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');
222
+
223
+                $event = $this->activityManager->generateEvent();
224
+                $event->setApp('files_sharing')
225
+                    ->setType('remote_share')
226
+                    ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')])
227
+                    ->setAffectedUser($shareWith)
228
+                    ->setObject('remote_share', (int)$shareId, $name);
229
+                \OC::$server->getActivityManager()->publish($event);
230
+
231
+                $notification = $this->notificationManager->createNotification();
232
+                $notification->setApp('files_sharing')
233
+                    ->setUser($shareWith)
234
+                    ->setDateTime(new \DateTime())
235
+                    ->setObject('remote_share', $shareId)
236
+                    ->setSubject('remote_share', [$ownerFederatedId, $sharedByFederatedId, trim($name, '/')]);
237
+
238
+                $declineAction = $notification->createAction();
239
+                $declineAction->setLabel('decline')
240
+                    ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE');
241
+                $notification->addAction($declineAction);
242
+
243
+                $acceptAction = $notification->createAction();
244
+                $acceptAction->setLabel('accept')
245
+                    ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST');
246
+                $notification->addAction($acceptAction);
247
+
248
+                $this->notificationManager->notify($notification);
249
+
250
+                return $shareId;
251
+            } catch (\Exception $e) {
252
+                $this->logger->logException($e, [
253
+                    'message' => 'Server can not add remote share.',
254
+                    'level' => ILogger::ERROR,
255
+                    'app' => 'files_sharing'
256
+                ]);
257
+                throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR);
258
+            }
259
+        }
260
+
261
+        throw new ProviderCouldNotAddShareException('server can not add remote share, missing parameter', '', HTTP::STATUS_BAD_REQUEST);
262
+
263
+    }
264
+
265
+    /**
266
+     * notification received from another server
267
+     *
268
+     * @param string $notificationType (e.g. SHARE_ACCEPTED)
269
+     * @param string $providerId id of the share
270
+     * @param array $notification payload of the notification
271
+     * @return array data send back to the sender
272
+     *
273
+     * @throws ActionNotSupportedException
274
+     * @throws AuthenticationFailedException
275
+     * @throws BadRequestException
276
+     * @throws \OC\HintException
277
+     * @since 14.0.0
278
+     */
279
+    public function notificationReceived($notificationType, $providerId, array $notification) {
280
+
281
+        switch ($notificationType) {
282
+            case 'SHARE_ACCEPTED':
283
+                return $this->shareAccepted($providerId, $notification);
284
+            case 'SHARE_DECLINED':
285
+                return $this->shareDeclined($providerId, $notification);
286
+            case 'SHARE_UNSHARED':
287
+                return $this->unshare($providerId, $notification);
288
+            case 'REQUEST_RESHARE':
289
+                return $this->reshareRequested($providerId, $notification);
290
+            case 'RESHARE_UNDO':
291
+                return $this->undoReshare($providerId, $notification);
292
+            case 'RESHARE_CHANGE_PERMISSION':
293
+                return $this->updateResharePermissions($providerId, $notification);
294
+        }
295
+
296
+
297
+        throw new BadRequestException([$notificationType]);
298
+    }
299
+
300
+    /**
301
+     * process notification that the recipient accepted a share
302
+     *
303
+     * @param string $id
304
+     * @param array $notification
305
+     * @return array
306
+     * @throws ActionNotSupportedException
307
+     * @throws AuthenticationFailedException
308
+     * @throws BadRequestException
309
+     * @throws \OC\HintException
310
+     */
311
+    private function shareAccepted($id, array $notification) {
312
+
313
+        if (!$this->isS2SEnabled()) {
314
+            throw new ActionNotSupportedException('Server does not support federated cloud sharing');
315
+        }
316
+
317
+        if (!isset($notification['sharedSecret'])) {
318
+            throw new BadRequestException(['sharedSecret']);
319
+        }
320
+
321
+        $token = $notification['sharedSecret'];
322
+
323
+        $share = $this->federatedShareProvider->getShareById($id);
324
+
325
+        $this->verifyShare($share, $token);
326
+        $this->executeAcceptShare($share);
327
+        if ($share->getShareOwner() !== $share->getSharedBy()) {
328
+            list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
329
+            $remoteId = $this->federatedShareProvider->getRemoteId($share);
330
+            $notification = $this->cloudFederationFactory->getCloudFederationNotification();
331
+            $notification->setMessage(
332
+                'SHARE_ACCEPTED',
333
+                'file',
334
+                $remoteId,
335
+                [
336
+                    'sharedSecret' => $token,
337
+                    'message' => 'Recipient accepted the re-share'
338
+                ]
339
+
340
+            );
341
+            $this->cloudFederationProviderManager->sendNotification($remote, $notification);
342
+
343
+        }
344
+
345
+        return [];
346
+    }
347
+
348
+    /**
349
+     * @param IShare $share
350
+     * @throws ShareNotFound
351
+     */
352
+    protected function executeAcceptShare(IShare $share) {
353
+        try {
354
+            $fileId = (int)$share->getNode()->getId();
355
+            list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
356
+        } catch (\Exception $e) {
357
+            throw new ShareNotFound();
358
+        }
359
+
360
+        $event = $this->activityManager->generateEvent();
361
+        $event->setApp('files_sharing')
362
+            ->setType('remote_share')
363
+            ->setAffectedUser($this->getCorrectUid($share))
364
+            ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_ACCEPTED, [$share->getSharedWith(), [$fileId => $file]])
365
+            ->setObject('files', $fileId, $file)
366
+            ->setLink($link);
367
+        $this->activityManager->publish($event);
368
+    }
369
+
370
+    /**
371
+     * process notification that the recipient declined a share
372
+     *
373
+     * @param string $id
374
+     * @param array $notification
375
+     * @return array
376
+     * @throws ActionNotSupportedException
377
+     * @throws AuthenticationFailedException
378
+     * @throws BadRequestException
379
+     * @throws ShareNotFound
380
+     * @throws \OC\HintException
381
+     *
382
+     */
383
+    protected function shareDeclined($id, array $notification) {
384
+
385
+        if (!$this->isS2SEnabled()) {
386
+            throw new ActionNotSupportedException('Server does not support federated cloud sharing');
387
+        }
388
+
389
+        if (!isset($notification['sharedSecret'])) {
390
+            throw new BadRequestException(['sharedSecret']);
391
+        }
392
+
393
+        $token = $notification['sharedSecret'];
394
+
395
+        $share = $this->federatedShareProvider->getShareById($id);
396
+
397
+        $this->verifyShare($share, $token);
398
+
399
+        if ($share->getShareOwner() !== $share->getSharedBy()) {
400
+            list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy());
401
+            $remoteId = $this->federatedShareProvider->getRemoteId($share);
402
+            $notification = $this->cloudFederationFactory->getCloudFederationNotification();
403
+            $notification->setMessage(
404
+                'SHARE_DECLINED',
405
+                'file',
406
+                $remoteId,
407
+                [
408
+                    'sharedSecret' => $token,
409
+                    'message' => 'Recipient declined the re-share'
410
+                ]
411
+
412
+            );
413
+            $this->cloudFederationProviderManager->sendNotification($remote, $notification);
414
+        }
415
+
416
+        $this->executeDeclineShare($share);
417
+
418
+        return [];
419
+
420
+    }
421
+
422
+    /**
423
+     * delete declined share and create a activity
424
+     *
425
+     * @param IShare $share
426
+     * @throws ShareNotFound
427
+     */
428
+    protected function executeDeclineShare(IShare $share) {
429
+        $this->federatedShareProvider->removeShareFromTable($share);
430
+
431
+        try {
432
+            $fileId = (int)$share->getNode()->getId();
433
+            list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId);
434
+        } catch (\Exception $e) {
435
+            throw new ShareNotFound();
436
+        }
437
+
438
+        $event = $this->activityManager->generateEvent();
439
+        $event->setApp('files_sharing')
440
+            ->setType('remote_share')
441
+            ->setAffectedUser($this->getCorrectUid($share))
442
+            ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]])
443
+            ->setObject('files', $fileId, $file)
444
+            ->setLink($link);
445
+        $this->activityManager->publish($event);
446
+
447
+    }
448
+
449
+    /**
450
+     * received the notification that the owner unshared a file from you
451
+     *
452
+     * @param string $id
453
+     * @param array $notification
454
+     * @return array
455
+     * @throws AuthenticationFailedException
456
+     * @throws BadRequestException
457
+     */
458
+    private function undoReshare($id, array $notification) {
459
+        if (!isset($notification['sharedSecret'])) {
460
+            throw new BadRequestException(['sharedSecret']);
461
+        }
462
+        $token = $notification['sharedSecret'];
463
+
464
+        $share = $this->federatedShareProvider->getShareById($id);
465
+
466
+        $this->verifyShare($share, $token);
467
+        $this->federatedShareProvider->removeShareFromTable($share);
468
+        return [];
469
+    }
470
+
471
+    /**
472
+     * unshare file from self
473
+     *
474
+     * @param string $id
475
+     * @param array $notification
476
+     * @return array
477
+     * @throws ActionNotSupportedException
478
+     * @throws BadRequestException
479
+     */
480
+    private function unshare($id, array $notification) {
481
+
482
+        if (!$this->isS2SEnabled(true)) {
483
+            throw new ActionNotSupportedException("incoming shares disabled!");
484
+        }
485
+
486
+        if (!isset($notification['sharedSecret'])) {
487
+            throw new BadRequestException(['sharedSecret']);
488
+        }
489
+        $token = $notification['sharedSecret'];
490
+
491
+        $qb = $this->connection->getQueryBuilder();
492
+        $qb->select('*')
493
+            ->from('share_external')
494
+            ->where(
495
+                $qb->expr()->andX(
496
+                    $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
497
+                    $qb->expr()->eq('share_token', $qb->createNamedParameter($token))
498
+                )
499
+            );
500
+
501
+        $result = $qb->execute();
502
+        $share = $result->fetch();
503
+        $result->closeCursor();
504
+
505
+        if ($token && $id && !empty($share)) {
506
+
507
+            $remote = $this->cleanupRemote($share['remote']);
508
+
509
+            $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote);
510
+            $mountpoint = $share['mountpoint'];
511
+            $user = $share['user'];
512
+
513
+            $qb = $this->connection->getQueryBuilder();
514
+            $qb->delete('share_external')
515
+                ->where(
516
+                    $qb->expr()->andX(
517
+                        $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
518
+                        $qb->expr()->eq('share_token', $qb->createNamedParameter($token))
519
+                    )
520
+                );
521
+
522
+            $qb->execute();
523
+
524
+            if ($share['accepted']) {
525
+                $path = trim($mountpoint, '/');
526
+            } else {
527
+                $path = trim($share['name'], '/');
528
+            }
529
+
530
+            $notification = $this->notificationManager->createNotification();
531
+            $notification->setApp('files_sharing')
532
+                ->setUser($share['user'])
533
+                ->setObject('remote_share', (int)$share['id']);
534
+            $this->notificationManager->markProcessed($notification);
535
+
536
+            $event = $this->activityManager->generateEvent();
537
+            $event->setApp('files_sharing')
538
+                ->setType('remote_share')
539
+                ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path])
540
+                ->setAffectedUser($user)
541
+                ->setObject('remote_share', (int)$share['id'], $path);
542
+            \OC::$server->getActivityManager()->publish($event);
543
+        }
544
+
545
+        return [];
546
+    }
547
+
548
+    private function cleanupRemote($remote) {
549
+        $remote = substr($remote, strpos($remote, '://') + 3);
550
+
551
+        return rtrim($remote, '/');
552
+    }
553
+
554
+    /**
555
+     * recipient of a share request to re-share the file with another user
556
+     *
557
+     * @param string $id
558
+     * @param array $notification
559
+     * @return array
560
+     * @throws AuthenticationFailedException
561
+     * @throws BadRequestException
562
+     * @throws ProviderCouldNotAddShareException
563
+     * @throws ShareNotFound
564
+     */
565
+    protected function reshareRequested($id, array $notification) {
566
+
567
+        if (!isset($notification['sharedSecret'])) {
568
+            throw new BadRequestException(['sharedSecret']);
569
+        }
570
+        $token = $notification['sharedSecret'];
571
+
572
+        if (!isset($notification['shareWith'])) {
573
+            throw new BadRequestException(['shareWith']);
574
+        }
575
+        $shareWith = $notification['shareWith'];
576
+
577
+        if (!isset($notification['senderId'])) {
578
+            throw new BadRequestException(['senderId']);
579
+        }
580
+        $senderId = $notification['senderId'];
581
+
582
+        $share = $this->federatedShareProvider->getShareById($id);
583
+        // don't allow to share a file back to the owner
584
+        try {
585
+            list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith);
586
+            $owner = $share->getShareOwner();
587
+            $currentServer = $this->addressHandler->generateRemoteURL();
588
+            if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) {
589
+                throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id);
590
+            }
591
+        } catch (\Exception $e) {
592
+            throw new ProviderCouldNotAddShareException($e->getMessage());
593
+        }
594
+
595
+        $this->verifyShare($share, $token);
596
+
597
+        // check if re-sharing is allowed
598
+        if ($share->getPermissions() & Constants::PERMISSION_SHARE) {
599
+            // the recipient of the initial share is now the initiator for the re-share
600
+            $share->setSharedBy($share->getSharedWith());
601
+            $share->setSharedWith($shareWith);
602
+            $result = $this->federatedShareProvider->create($share);
603
+            $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId);
604
+            return ['token' => $result->getToken(), 'providerId' => $result->getId()];
605
+        } else {
606
+            throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id);
607
+        }
608
+
609
+    }
610
+
611
+    /**
612
+     * update permission of a re-share so that the share dialog shows the right
613
+     * permission if the owner or the sender changes the permission
614
+     *
615
+     * @param string $id
616
+     * @param array $notification
617
+     * @return array
618
+     * @throws AuthenticationFailedException
619
+     * @throws BadRequestException
620
+     */
621
+    protected function updateResharePermissions($id, array $notification) {
622
+
623
+        if (!isset($notification['sharedSecret'])) {
624
+            throw new BadRequestException(['sharedSecret']);
625
+        }
626
+        $token = $notification['sharedSecret'];
627
+
628
+        if (!isset($notification['permission'])) {
629
+            throw new BadRequestException(['permission']);
630
+        }
631
+        $ocmPermissions = $notification['permission'];
632
+
633
+        $share = $this->federatedShareProvider->getShareById($id);
634
+
635
+        $ncPermission = $this->ocmPermissions2ncPermissions($ocmPermissions);
636
+
637
+        $this->verifyShare($share, $token);
638
+        $this->updatePermissionsInDatabase($share, $ncPermission);
639
+
640
+        return [];
641
+    }
642
+
643
+    /**
644
+     * translate OCM Permissions to Nextcloud permissions
645
+     *
646
+     * @param array $ocmPermissions
647
+     * @return int
648
+     * @throws BadRequestException
649
+     */
650
+    protected function ocmPermissions2ncPermissions(array $ocmPermissions) {
651
+        $ncPermissions = 0;
652
+        foreach($ocmPermissions as $permission) {
653
+            switch (strtolower($permission)) {
654
+                case 'read':
655
+                    $ncPermissions += Constants::PERMISSION_READ;
656
+                    break;
657
+                case 'write':
658
+                    $ncPermissions += Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE;
659
+                    break;
660
+                case 'share':
661
+                    $ncPermissions += Constants::PERMISSION_SHARE;
662
+                    break;
663
+                default:
664
+                    throw new BadRequestException(['permission']);
665
+            }
666
+
667
+            error_log("new permissions: " . $ncPermissions);
668
+        }
669
+
670
+        return $ncPermissions;
671
+    }
672
+
673
+    /**
674
+     * update permissions in database
675
+     *
676
+     * @param IShare $share
677
+     * @param int $permissions
678
+     */
679
+    protected function updatePermissionsInDatabase(IShare $share, $permissions) {
680
+        $query = $this->connection->getQueryBuilder();
681
+        $query->update('share')
682
+            ->where($query->expr()->eq('id', $query->createNamedParameter($share->getId())))
683
+            ->set('permissions', $query->createNamedParameter($permissions))
684
+            ->execute();
685
+    }
686
+
687
+
688
+    /**
689
+     * get file
690
+     *
691
+     * @param string $user
692
+     * @param int $fileSource
693
+     * @return array with internal path of the file and a absolute link to it
694
+     */
695
+    private function getFile($user, $fileSource) {
696
+        \OC_Util::setupFS($user);
697
+
698
+        try {
699
+            $file = Filesystem::getPath($fileSource);
700
+        } catch (NotFoundException $e) {
701
+            $file = null;
702
+        }
703
+        $args = Filesystem::is_dir($file) ? array('dir' => $file) : array('dir' => dirname($file), 'scrollto' => $file);
704
+        $link = Util::linkToAbsolute('files', 'index.php', $args);
705
+
706
+        return [$file, $link];
707
+
708
+    }
709
+
710
+    /**
711
+     * check if we are the initiator or the owner of a re-share and return the correct UID
712
+     *
713
+     * @param IShare $share
714
+     * @return string
715
+     */
716
+    protected function getCorrectUid(IShare $share) {
717
+        if ($this->userManager->userExists($share->getShareOwner())) {
718
+            return $share->getShareOwner();
719
+        }
720
+
721
+        return $share->getSharedBy();
722
+    }
723
+
724
+
725
+
726
+    /**
727
+     * check if we got the right share
728
+     *
729
+     * @param IShare $share
730
+     * @param string $token
731
+     * @return bool
732
+     * @throws AuthenticationFailedException
733
+     */
734
+    protected function verifyShare(IShare $share, $token) {
735
+        if (
736
+            $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE &&
737
+            $share->getToken() === $token
738
+        ) {
739
+            return true;
740
+        }
741
+
742
+        throw new AuthenticationFailedException();
743
+    }
744
+
745
+
746
+
747
+    /**
748
+     * check if server-to-server sharing is enabled
749
+     *
750
+     * @param bool $incoming
751
+     * @return bool
752
+     */
753
+    private function isS2SEnabled($incoming = false) {
754
+
755
+        $result = $this->appManager->isEnabledForUser('files_sharing');
756
+
757
+        if ($incoming) {
758
+            $result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();
759
+        } else {
760
+            $result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
761
+        }
762
+
763
+        return $result;
764
+    }
765 765
 
766 766
 
767 767
 }
Please login to merge, or discard this patch.
ocm-provider/index.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@
 block discarded – undo
29 29
 $isEnabled = $server->getAppManager()->isEnabledForUser('cloud_federation_api');
30 30
 
31 31
 if ($isEnabled) {
32
-	$capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator());
33
-	header('Content-Type: application/json');
34
-	echo json_encode($capabilities->getCapabilities()['ocm']);
32
+    $capabilities = new OCA\CloudFederationAPI\Capabilities($server->getURLGenerator());
33
+    header('Content-Type: application/json');
34
+    echo json_encode($capabilities->getCapabilities()['ocm']);
35 35
 } else {
36
-	header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501);
37
-	exit("501 Not Implemented");
36
+    header($_SERVER["SERVER_PROTOCOL"]." 501 Not Implemented", true, 501);
37
+    exit("501 Not Implemented");
38 38
 }
39 39
 
Please login to merge, or discard this patch.
apps/cloud_federation_api/lib/AppInfo/Application.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
28 28
 
29 29
 class Application extends App {
30 30
 
31
-	public function __construct() {
32
-		parent::__construct('cloud_federation_api');
31
+    public function __construct() {
32
+        parent::__construct('cloud_federation_api');
33 33
 
34
-		$container = $this->getContainer();
35
-		$container->registerCapability(Capabilities::class);
36
-	}
34
+        $container = $this->getContainer();
35
+        $container->registerCapability(Capabilities::class);
36
+    }
37 37
 }
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.
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.
lib/private/Share20/ProviderFactory.php 1 patch
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -48,235 +48,235 @@
 block discarded – undo
48 48
  */
49 49
 class ProviderFactory implements IProviderFactory {
50 50
 
51
-	/** @var IServerContainer */
52
-	private $serverContainer;
53
-	/** @var DefaultShareProvider */
54
-	private $defaultProvider = null;
55
-	/** @var FederatedShareProvider */
56
-	private $federatedProvider = null;
57
-	/** @var  ShareByMailProvider */
58
-	private $shareByMailProvider;
59
-	/** @var  \OCA\Circles\ShareByCircleProvider */
60
-	private $shareByCircleProvider = null;
61
-	/** @var bool */
62
-	private $circlesAreNotAvailable = false;
63
-
64
-	/**
65
-	 * IProviderFactory constructor.
66
-	 *
67
-	 * @param IServerContainer $serverContainer
68
-	 */
69
-	public function __construct(IServerContainer $serverContainer) {
70
-		$this->serverContainer = $serverContainer;
71
-	}
72
-
73
-	/**
74
-	 * Create the default share provider.
75
-	 *
76
-	 * @return DefaultShareProvider
77
-	 */
78
-	protected function defaultShareProvider() {
79
-		if ($this->defaultProvider === null) {
80
-			$this->defaultProvider = new DefaultShareProvider(
81
-				$this->serverContainer->getDatabaseConnection(),
82
-				$this->serverContainer->getUserManager(),
83
-				$this->serverContainer->getGroupManager(),
84
-				$this->serverContainer->getLazyRootFolder()
85
-			);
86
-		}
87
-
88
-		return $this->defaultProvider;
89
-	}
90
-
91
-	/**
92
-	 * Create the federated share provider
93
-	 *
94
-	 * @return FederatedShareProvider
95
-	 */
96
-	protected function federatedShareProvider() {
97
-		if ($this->federatedProvider === null) {
98
-			/*
51
+    /** @var IServerContainer */
52
+    private $serverContainer;
53
+    /** @var DefaultShareProvider */
54
+    private $defaultProvider = null;
55
+    /** @var FederatedShareProvider */
56
+    private $federatedProvider = null;
57
+    /** @var  ShareByMailProvider */
58
+    private $shareByMailProvider;
59
+    /** @var  \OCA\Circles\ShareByCircleProvider */
60
+    private $shareByCircleProvider = null;
61
+    /** @var bool */
62
+    private $circlesAreNotAvailable = false;
63
+
64
+    /**
65
+     * IProviderFactory constructor.
66
+     *
67
+     * @param IServerContainer $serverContainer
68
+     */
69
+    public function __construct(IServerContainer $serverContainer) {
70
+        $this->serverContainer = $serverContainer;
71
+    }
72
+
73
+    /**
74
+     * Create the default share provider.
75
+     *
76
+     * @return DefaultShareProvider
77
+     */
78
+    protected function defaultShareProvider() {
79
+        if ($this->defaultProvider === null) {
80
+            $this->defaultProvider = new DefaultShareProvider(
81
+                $this->serverContainer->getDatabaseConnection(),
82
+                $this->serverContainer->getUserManager(),
83
+                $this->serverContainer->getGroupManager(),
84
+                $this->serverContainer->getLazyRootFolder()
85
+            );
86
+        }
87
+
88
+        return $this->defaultProvider;
89
+    }
90
+
91
+    /**
92
+     * Create the federated share provider
93
+     *
94
+     * @return FederatedShareProvider
95
+     */
96
+    protected function federatedShareProvider() {
97
+        if ($this->federatedProvider === null) {
98
+            /*
99 99
 			 * Check if the app is enabled
100 100
 			 */
101
-			$appManager = $this->serverContainer->getAppManager();
102
-			if (!$appManager->isEnabledForUser('federatedfilesharing')) {
103
-				return null;
104
-			}
101
+            $appManager = $this->serverContainer->getAppManager();
102
+            if (!$appManager->isEnabledForUser('federatedfilesharing')) {
103
+                return null;
104
+            }
105 105
 
106
-			/*
106
+            /*
107 107
 			 * TODO: add factory to federated sharing app
108 108
 			 */
109
-			$l = $this->serverContainer->getL10N('federatedfilessharing');
110
-			$addressHandler = new AddressHandler(
111
-				$this->serverContainer->getURLGenerator(),
112
-				$l,
113
-				$this->serverContainer->getCloudIdManager()
114
-			);
115
-			$notifications = new Notifications(
116
-				$addressHandler,
117
-				$this->serverContainer->getHTTPClientService(),
118
-				$this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
119
-				$this->serverContainer->getJobList(),
120
-				\OC::$server->getCloudFederationProviderManager(),
121
-				\OC::$server->getCloudFederationFactory()
122
-			);
123
-			$tokenHandler = new TokenHandler(
124
-				$this->serverContainer->getSecureRandom()
125
-			);
126
-
127
-			$this->federatedProvider = new FederatedShareProvider(
128
-				$this->serverContainer->getDatabaseConnection(),
129
-				$addressHandler,
130
-				$notifications,
131
-				$tokenHandler,
132
-				$l,
133
-				$this->serverContainer->getLogger(),
134
-				$this->serverContainer->getLazyRootFolder(),
135
-				$this->serverContainer->getConfig(),
136
-				$this->serverContainer->getUserManager(),
137
-				$this->serverContainer->getCloudIdManager(),
138
-				$this->serverContainer->getGlobalScaleConfig()
139
-			);
140
-		}
141
-
142
-		return $this->federatedProvider;
143
-	}
144
-
145
-	/**
146
-	 * Create the federated share provider
147
-	 *
148
-	 * @return ShareByMailProvider
149
-	 */
150
-	protected function getShareByMailProvider() {
151
-		if ($this->shareByMailProvider === null) {
152
-			/*
109
+            $l = $this->serverContainer->getL10N('federatedfilessharing');
110
+            $addressHandler = new AddressHandler(
111
+                $this->serverContainer->getURLGenerator(),
112
+                $l,
113
+                $this->serverContainer->getCloudIdManager()
114
+            );
115
+            $notifications = new Notifications(
116
+                $addressHandler,
117
+                $this->serverContainer->getHTTPClientService(),
118
+                $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
119
+                $this->serverContainer->getJobList(),
120
+                \OC::$server->getCloudFederationProviderManager(),
121
+                \OC::$server->getCloudFederationFactory()
122
+            );
123
+            $tokenHandler = new TokenHandler(
124
+                $this->serverContainer->getSecureRandom()
125
+            );
126
+
127
+            $this->federatedProvider = new FederatedShareProvider(
128
+                $this->serverContainer->getDatabaseConnection(),
129
+                $addressHandler,
130
+                $notifications,
131
+                $tokenHandler,
132
+                $l,
133
+                $this->serverContainer->getLogger(),
134
+                $this->serverContainer->getLazyRootFolder(),
135
+                $this->serverContainer->getConfig(),
136
+                $this->serverContainer->getUserManager(),
137
+                $this->serverContainer->getCloudIdManager(),
138
+                $this->serverContainer->getGlobalScaleConfig()
139
+            );
140
+        }
141
+
142
+        return $this->federatedProvider;
143
+    }
144
+
145
+    /**
146
+     * Create the federated share provider
147
+     *
148
+     * @return ShareByMailProvider
149
+     */
150
+    protected function getShareByMailProvider() {
151
+        if ($this->shareByMailProvider === null) {
152
+            /*
153 153
 			 * Check if the app is enabled
154 154
 			 */
155
-			$appManager = $this->serverContainer->getAppManager();
156
-			if (!$appManager->isEnabledForUser('sharebymail')) {
157
-				return null;
158
-			}
159
-
160
-			$settingsManager = new SettingsManager($this->serverContainer->getConfig());
161
-
162
-			$this->shareByMailProvider = new ShareByMailProvider(
163
-				$this->serverContainer->getDatabaseConnection(),
164
-				$this->serverContainer->getSecureRandom(),
165
-				$this->serverContainer->getUserManager(),
166
-				$this->serverContainer->getLazyRootFolder(),
167
-				$this->serverContainer->getL10N('sharebymail'),
168
-				$this->serverContainer->getLogger(),
169
-				$this->serverContainer->getMailer(),
170
-				$this->serverContainer->getURLGenerator(),
171
-				$this->serverContainer->getActivityManager(),
172
-				$settingsManager,
173
-				$this->serverContainer->query(Defaults::class),
174
-				$this->serverContainer->getHasher(),
175
-				$this->serverContainer->query(CapabilitiesManager::class)
176
-			);
177
-		}
178
-
179
-		return $this->shareByMailProvider;
180
-	}
181
-
182
-
183
-	/**
184
-	 * Create the circle share provider
185
-	 *
186
-	 * @return FederatedShareProvider
187
-	 *
188
-	 * @suppress PhanUndeclaredClassMethod
189
-	 */
190
-	protected function getShareByCircleProvider() {
191
-
192
-		if ($this->circlesAreNotAvailable) {
193
-			return null;
194
-		}
195
-
196
-		if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') ||
197
-			!class_exists('\OCA\Circles\ShareByCircleProvider')
198
-		) {
199
-			$this->circlesAreNotAvailable = true;
200
-			return null;
201
-		}
202
-
203
-		if ($this->shareByCircleProvider === null) {
204
-
205
-			$this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider(
206
-				$this->serverContainer->getDatabaseConnection(),
207
-				$this->serverContainer->getSecureRandom(),
208
-				$this->serverContainer->getUserManager(),
209
-				$this->serverContainer->getLazyRootFolder(),
210
-				$this->serverContainer->getL10N('circles'),
211
-				$this->serverContainer->getLogger(),
212
-				$this->serverContainer->getURLGenerator()
213
-			);
214
-		}
215
-
216
-		return $this->shareByCircleProvider;
217
-	}
218
-
219
-
220
-	/**
221
-	 * @inheritdoc
222
-	 */
223
-	public function getProvider($id) {
224
-		$provider = null;
225
-		if ($id === 'ocinternal') {
226
-			$provider = $this->defaultShareProvider();
227
-		} else if ($id === 'ocFederatedSharing') {
228
-			$provider = $this->federatedShareProvider();
229
-		} else if ($id === 'ocMailShare') {
230
-			$provider = $this->getShareByMailProvider();
231
-		} else if ($id === 'ocCircleShare') {
232
-			$provider = $this->getShareByCircleProvider();
233
-		}
234
-
235
-		if ($provider === null) {
236
-			throw new ProviderException('No provider with id .' . $id . ' found.');
237
-		}
238
-
239
-		return $provider;
240
-	}
241
-
242
-	/**
243
-	 * @inheritdoc
244
-	 */
245
-	public function getProviderForType($shareType) {
246
-		$provider = null;
247
-
248
-		if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
249
-			$shareType === \OCP\Share::SHARE_TYPE_GROUP ||
250
-			$shareType === \OCP\Share::SHARE_TYPE_LINK
251
-		) {
252
-			$provider = $this->defaultShareProvider();
253
-		} else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
254
-			$provider = $this->federatedShareProvider();
255
-		} else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
256
-			$provider = $this->getShareByMailProvider();
257
-		} else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
258
-			$provider = $this->getShareByCircleProvider();
259
-		}
260
-
261
-
262
-		if ($provider === null) {
263
-			throw new ProviderException('No share provider for share type ' . $shareType);
264
-		}
265
-
266
-		return $provider;
267
-	}
268
-
269
-	public function getAllProviders() {
270
-		$shares = [$this->defaultShareProvider(), $this->federatedShareProvider()];
271
-		$shareByMail = $this->getShareByMailProvider();
272
-		if ($shareByMail !== null) {
273
-			$shares[] = $shareByMail;
274
-		}
275
-		$shareByCircle = $this->getShareByCircleProvider();
276
-		if ($shareByCircle !== null) {
277
-			$shares[] = $shareByCircle;
278
-		}
279
-
280
-		return $shares;
281
-	}
155
+            $appManager = $this->serverContainer->getAppManager();
156
+            if (!$appManager->isEnabledForUser('sharebymail')) {
157
+                return null;
158
+            }
159
+
160
+            $settingsManager = new SettingsManager($this->serverContainer->getConfig());
161
+
162
+            $this->shareByMailProvider = new ShareByMailProvider(
163
+                $this->serverContainer->getDatabaseConnection(),
164
+                $this->serverContainer->getSecureRandom(),
165
+                $this->serverContainer->getUserManager(),
166
+                $this->serverContainer->getLazyRootFolder(),
167
+                $this->serverContainer->getL10N('sharebymail'),
168
+                $this->serverContainer->getLogger(),
169
+                $this->serverContainer->getMailer(),
170
+                $this->serverContainer->getURLGenerator(),
171
+                $this->serverContainer->getActivityManager(),
172
+                $settingsManager,
173
+                $this->serverContainer->query(Defaults::class),
174
+                $this->serverContainer->getHasher(),
175
+                $this->serverContainer->query(CapabilitiesManager::class)
176
+            );
177
+        }
178
+
179
+        return $this->shareByMailProvider;
180
+    }
181
+
182
+
183
+    /**
184
+     * Create the circle share provider
185
+     *
186
+     * @return FederatedShareProvider
187
+     *
188
+     * @suppress PhanUndeclaredClassMethod
189
+     */
190
+    protected function getShareByCircleProvider() {
191
+
192
+        if ($this->circlesAreNotAvailable) {
193
+            return null;
194
+        }
195
+
196
+        if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') ||
197
+            !class_exists('\OCA\Circles\ShareByCircleProvider')
198
+        ) {
199
+            $this->circlesAreNotAvailable = true;
200
+            return null;
201
+        }
202
+
203
+        if ($this->shareByCircleProvider === null) {
204
+
205
+            $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider(
206
+                $this->serverContainer->getDatabaseConnection(),
207
+                $this->serverContainer->getSecureRandom(),
208
+                $this->serverContainer->getUserManager(),
209
+                $this->serverContainer->getLazyRootFolder(),
210
+                $this->serverContainer->getL10N('circles'),
211
+                $this->serverContainer->getLogger(),
212
+                $this->serverContainer->getURLGenerator()
213
+            );
214
+        }
215
+
216
+        return $this->shareByCircleProvider;
217
+    }
218
+
219
+
220
+    /**
221
+     * @inheritdoc
222
+     */
223
+    public function getProvider($id) {
224
+        $provider = null;
225
+        if ($id === 'ocinternal') {
226
+            $provider = $this->defaultShareProvider();
227
+        } else if ($id === 'ocFederatedSharing') {
228
+            $provider = $this->federatedShareProvider();
229
+        } else if ($id === 'ocMailShare') {
230
+            $provider = $this->getShareByMailProvider();
231
+        } else if ($id === 'ocCircleShare') {
232
+            $provider = $this->getShareByCircleProvider();
233
+        }
234
+
235
+        if ($provider === null) {
236
+            throw new ProviderException('No provider with id .' . $id . ' found.');
237
+        }
238
+
239
+        return $provider;
240
+    }
241
+
242
+    /**
243
+     * @inheritdoc
244
+     */
245
+    public function getProviderForType($shareType) {
246
+        $provider = null;
247
+
248
+        if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
249
+            $shareType === \OCP\Share::SHARE_TYPE_GROUP ||
250
+            $shareType === \OCP\Share::SHARE_TYPE_LINK
251
+        ) {
252
+            $provider = $this->defaultShareProvider();
253
+        } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
254
+            $provider = $this->federatedShareProvider();
255
+        } else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
256
+            $provider = $this->getShareByMailProvider();
257
+        } else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
258
+            $provider = $this->getShareByCircleProvider();
259
+        }
260
+
261
+
262
+        if ($provider === null) {
263
+            throw new ProviderException('No share provider for share type ' . $shareType);
264
+        }
265
+
266
+        return $provider;
267
+    }
268
+
269
+    public function getAllProviders() {
270
+        $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()];
271
+        $shareByMail = $this->getShareByMailProvider();
272
+        if ($shareByMail !== null) {
273
+            $shares[] = $shareByMail;
274
+        }
275
+        $shareByCircle = $this->getShareByCircleProvider();
276
+        if ($shareByCircle !== null) {
277
+            $shares[] = $shareByCircle;
278
+        }
279
+
280
+        return $shares;
281
+    }
282 282
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/AppInfo/Application.php 1 patch
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -45,136 +45,136 @@
 block discarded – undo
45 45
 use OCA\Files_Sharing\External\Manager;
46 46
 
47 47
 class Application extends App {
48
-	public function __construct(array $urlParams = array()) {
49
-		parent::__construct('files_sharing', $urlParams);
48
+    public function __construct(array $urlParams = array()) {
49
+        parent::__construct('files_sharing', $urlParams);
50 50
 
51
-		$container = $this->getContainer();
52
-		/** @var IServerContainer $server */
53
-		$server = $container->getServer();
51
+        $container = $this->getContainer();
52
+        /** @var IServerContainer $server */
53
+        $server = $container->getServer();
54 54
 
55
-		/**
56
-		 * Controllers
57
-		 */
58
-		$container->registerService('ShareController', function (SimpleContainer $c) use ($server) {
59
-			$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
60
-			return new ShareController(
61
-				$c->query('AppName'),
62
-				$c->query('Request'),
63
-				$server->getConfig(),
64
-				$server->getURLGenerator(),
65
-				$server->getUserManager(),
66
-				$server->getLogger(),
67
-				$server->getActivityManager(),
68
-				$server->getShareManager(),
69
-				$server->getSession(),
70
-				$server->getPreviewManager(),
71
-				$server->getRootFolder(),
72
-				$federatedSharingApp->getFederatedShareProvider(),
73
-				$server->getEventDispatcher(),
74
-				$server->getL10N($c->query('AppName')),
75
-				$server->query(Defaults::class)
76
-			);
77
-		});
78
-		$container->registerService('ExternalSharesController', function (SimpleContainer $c) {
79
-			return new ExternalSharesController(
80
-				$c->query('AppName'),
81
-				$c->query('Request'),
82
-				$c->query('ExternalManager'),
83
-				$c->query('HttpClientService')
84
-			);
85
-		});
55
+        /**
56
+         * Controllers
57
+         */
58
+        $container->registerService('ShareController', function (SimpleContainer $c) use ($server) {
59
+            $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
60
+            return new ShareController(
61
+                $c->query('AppName'),
62
+                $c->query('Request'),
63
+                $server->getConfig(),
64
+                $server->getURLGenerator(),
65
+                $server->getUserManager(),
66
+                $server->getLogger(),
67
+                $server->getActivityManager(),
68
+                $server->getShareManager(),
69
+                $server->getSession(),
70
+                $server->getPreviewManager(),
71
+                $server->getRootFolder(),
72
+                $federatedSharingApp->getFederatedShareProvider(),
73
+                $server->getEventDispatcher(),
74
+                $server->getL10N($c->query('AppName')),
75
+                $server->query(Defaults::class)
76
+            );
77
+        });
78
+        $container->registerService('ExternalSharesController', function (SimpleContainer $c) {
79
+            return new ExternalSharesController(
80
+                $c->query('AppName'),
81
+                $c->query('Request'),
82
+                $c->query('ExternalManager'),
83
+                $c->query('HttpClientService')
84
+            );
85
+        });
86 86
 
87
-		/**
88
-		 * Core class wrappers
89
-		 */
90
-		$container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) {
91
-			return $server->getHTTPClientService();
92
-		});
93
-		$container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) {
94
-			return $server->getCloudIdManager();
95
-		});
96
-		$container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) {
97
-			$user = $server->getUserSession()->getUser();
98
-			$uid = $user ? $user->getUID() : null;
99
-			return new \OCA\Files_Sharing\External\Manager(
100
-				$server->getDatabaseConnection(),
101
-				\OC\Files\Filesystem::getMountManager(),
102
-				\OC\Files\Filesystem::getLoader(),
103
-				$server->getHTTPClientService(),
104
-				$server->getNotificationManager(),
105
-				$server->query(\OCP\OCS\IDiscoveryService::class),
106
-				$server->getCloudFederationProviderManager(),
107
-				$server->getCloudFederationFactory(),
108
-				$uid
109
-			);
110
-		});
111
-		$container->registerAlias(Manager::class, 'ExternalManager');
87
+        /**
88
+         * Core class wrappers
89
+         */
90
+        $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) {
91
+            return $server->getHTTPClientService();
92
+        });
93
+        $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) {
94
+            return $server->getCloudIdManager();
95
+        });
96
+        $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) {
97
+            $user = $server->getUserSession()->getUser();
98
+            $uid = $user ? $user->getUID() : null;
99
+            return new \OCA\Files_Sharing\External\Manager(
100
+                $server->getDatabaseConnection(),
101
+                \OC\Files\Filesystem::getMountManager(),
102
+                \OC\Files\Filesystem::getLoader(),
103
+                $server->getHTTPClientService(),
104
+                $server->getNotificationManager(),
105
+                $server->query(\OCP\OCS\IDiscoveryService::class),
106
+                $server->getCloudFederationProviderManager(),
107
+                $server->getCloudFederationFactory(),
108
+                $uid
109
+            );
110
+        });
111
+        $container->registerAlias(Manager::class, 'ExternalManager');
112 112
 
113
-		/**
114
-		 * Middleware
115
-		 */
116
-		$container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) {
117
-			return new SharingCheckMiddleware(
118
-				$c->query('AppName'),
119
-				$server->getConfig(),
120
-				$server->getAppManager(),
121
-				$c['ControllerMethodReflector'],
122
-				$server->getShareManager(),
123
-				$server->getRequest()
124
-			);
125
-		});
113
+        /**
114
+         * Middleware
115
+         */
116
+        $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) {
117
+            return new SharingCheckMiddleware(
118
+                $c->query('AppName'),
119
+                $server->getConfig(),
120
+                $server->getAppManager(),
121
+                $c['ControllerMethodReflector'],
122
+                $server->getShareManager(),
123
+                $server->getRequest()
124
+            );
125
+        });
126 126
 
127
-		$container->registerService('OCSShareAPIMiddleware', function (SimpleContainer $c) use ($server) {
128
-			return new OCSShareAPIMiddleware(
129
-				$server->getShareManager(),
130
-				$server->getL10N($c->query('AppName'))
131
-			);
132
-		});
127
+        $container->registerService('OCSShareAPIMiddleware', function (SimpleContainer $c) use ($server) {
128
+            return new OCSShareAPIMiddleware(
129
+                $server->getShareManager(),
130
+                $server->getL10N($c->query('AppName'))
131
+            );
132
+        });
133 133
 
134
-		$container->registerService(ShareInfoMiddleware::class, function () use ($server) {
135
-			return new ShareInfoMiddleware(
136
-				$server->getShareManager()
137
-			);
138
-		});
134
+        $container->registerService(ShareInfoMiddleware::class, function () use ($server) {
135
+            return new ShareInfoMiddleware(
136
+                $server->getShareManager()
137
+            );
138
+        });
139 139
 
140
-		// Execute middlewares
141
-		$container->registerMiddleWare('SharingCheckMiddleware');
142
-		$container->registerMiddleWare('OCSShareAPIMiddleware');
143
-		$container->registerMiddleWare(ShareInfoMiddleware::class);
140
+        // Execute middlewares
141
+        $container->registerMiddleWare('SharingCheckMiddleware');
142
+        $container->registerMiddleWare('OCSShareAPIMiddleware');
143
+        $container->registerMiddleWare(ShareInfoMiddleware::class);
144 144
 
145
-		$container->registerService('MountProvider', function (IContainer $c) {
146
-			/** @var \OCP\IServerContainer $server */
147
-			$server = $c->query('ServerContainer');
148
-			return new MountProvider(
149
-				$server->getConfig(),
150
-				$server->getShareManager(),
151
-				$server->getLogger()
152
-			);
153
-		});
145
+        $container->registerService('MountProvider', function (IContainer $c) {
146
+            /** @var \OCP\IServerContainer $server */
147
+            $server = $c->query('ServerContainer');
148
+            return new MountProvider(
149
+                $server->getConfig(),
150
+                $server->getShareManager(),
151
+                $server->getLogger()
152
+            );
153
+        });
154 154
 
155
-		$container->registerService('ExternalMountProvider', function (IContainer $c) {
156
-			/** @var \OCP\IServerContainer $server */
157
-			$server = $c->query('ServerContainer');
158
-			return new \OCA\Files_Sharing\External\MountProvider(
159
-				$server->getDatabaseConnection(),
160
-				function() use ($c) {
161
-					return $c->query('ExternalManager');
162
-				},
163
-				$server->getCloudIdManager()
164
-			);
165
-		});
155
+        $container->registerService('ExternalMountProvider', function (IContainer $c) {
156
+            /** @var \OCP\IServerContainer $server */
157
+            $server = $c->query('ServerContainer');
158
+            return new \OCA\Files_Sharing\External\MountProvider(
159
+                $server->getDatabaseConnection(),
160
+                function() use ($c) {
161
+                    return $c->query('ExternalManager');
162
+                },
163
+                $server->getCloudIdManager()
164
+            );
165
+        });
166 166
 
167
-		/*
167
+        /*
168 168
 		 * Register capabilities
169 169
 		 */
170
-		$container->registerCapability(Capabilities::class);
171
-	}
170
+        $container->registerCapability(Capabilities::class);
171
+    }
172 172
 
173
-	public function registerMountProviders() {
174
-		/** @var \OCP\IServerContainer $server */
175
-		$server = $this->getContainer()->query('ServerContainer');
176
-		$mountProviderCollection = $server->getMountProviderCollection();
177
-		$mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider'));
178
-		$mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider'));
179
-	}
173
+    public function registerMountProviders() {
174
+        /** @var \OCP\IServerContainer $server */
175
+        $server = $this->getContainer()->query('ServerContainer');
176
+        $mountProviderCollection = $server->getMountProviderCollection();
177
+        $mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider'));
178
+        $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider'));
179
+    }
180 180
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Hooks.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -32,33 +32,33 @@
 block discarded – undo
32 32
 
33 33
 class Hooks {
34 34
 
35
-	public static function deleteUser($params) {
36
-		$manager = new External\Manager(
37
-			\OC::$server->getDatabaseConnection(),
38
-			\OC\Files\Filesystem::getMountManager(),
39
-			\OC\Files\Filesystem::getLoader(),
40
-			\OC::$server->getHTTPClientService(),
41
-			\OC::$server->getNotificationManager(),
42
-			\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
43
-			\OC::$server->getCloudFederationProviderManager(),
44
-			\OC::$server->getCloudFederationFactory(),
45
-			$params['uid']);
35
+    public static function deleteUser($params) {
36
+        $manager = new External\Manager(
37
+            \OC::$server->getDatabaseConnection(),
38
+            \OC\Files\Filesystem::getMountManager(),
39
+            \OC\Files\Filesystem::getLoader(),
40
+            \OC::$server->getHTTPClientService(),
41
+            \OC::$server->getNotificationManager(),
42
+            \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
43
+            \OC::$server->getCloudFederationProviderManager(),
44
+            \OC::$server->getCloudFederationFactory(),
45
+            $params['uid']);
46 46
 
47
-		$manager->removeUserShares($params['uid']);
48
-	}
47
+        $manager->removeUserShares($params['uid']);
48
+    }
49 49
 
50
-	public static function unshareChildren($params) {
51
-		$path = Filesystem::getView()->getAbsolutePath($params['path']);
52
-		$view = new \OC\Files\View('/');
50
+    public static function unshareChildren($params) {
51
+        $path = Filesystem::getView()->getAbsolutePath($params['path']);
52
+        $view = new \OC\Files\View('/');
53 53
 
54
-		// find share mount points within $path and unmount them
55
-		$mountManager = \OC\Files\Filesystem::getMountManager();
56
-		$mountedShares = $mountManager->findIn($path);
57
-		foreach ($mountedShares as $mount) {
58
-			if ($mount->getStorage()->instanceOfStorage(ISharedStorage::class)) {
59
-				$mountPoint = $mount->getMountPoint();
60
-				$view->unlink($mountPoint);
61
-			}
62
-		}
63
-	}
54
+        // find share mount points within $path and unmount them
55
+        $mountManager = \OC\Files\Filesystem::getMountManager();
56
+        $mountedShares = $mountManager->findIn($path);
57
+        foreach ($mountedShares as $mount) {
58
+            if ($mount->getStorage()->instanceOfStorage(ISharedStorage::class)) {
59
+                $mountPoint = $mount->getMountPoint();
60
+                $view->unlink($mountPoint);
61
+            }
62
+        }
63
+    }
64 64
 }
Please login to merge, or discard this patch.