|
9 | 9 |
|
10 | 10 | use OC\OCM\OCMSignatoryManager; |
11 | 11 | use OCA\CloudFederationAPI\Config; |
12 | | -use OCA\CloudFederationAPI\Db\FederatedInviteMapper; |
13 | | -use OCA\CloudFederationAPI\Events\FederatedInviteAcceptedEvent; |
14 | 12 | use OCA\CloudFederationAPI\ResponseDefinitions; |
15 | 13 | use OCA\FederatedFileSharing\AddressHandler; |
16 | 14 | use OCP\AppFramework\Controller; |
17 | | -use OCP\AppFramework\Db\DoesNotExistException; |
18 | 15 | use OCP\AppFramework\Http; |
19 | 16 | use OCP\AppFramework\Http\Attribute\BruteForceProtection; |
20 | 17 | use OCP\AppFramework\Http\Attribute\NoCSRFRequired; |
21 | 18 | use OCP\AppFramework\Http\Attribute\OpenAPI; |
22 | 19 | use OCP\AppFramework\Http\Attribute\PublicPage; |
23 | 20 | use OCP\AppFramework\Http\JSONResponse; |
24 | 21 | use OCP\AppFramework\Utility\ITimeFactory; |
25 | | -use OCP\EventDispatcher\IEventDispatcher; |
26 | 22 | use OCP\Federation\Exceptions\ActionNotSupportedException; |
27 | 23 | use OCP\Federation\Exceptions\AuthenticationFailedException; |
28 | 24 | use OCP\Federation\Exceptions\BadRequestException; |
@@ -67,8 +63,6 @@ public function __construct( |
67 | 63 | private IURLGenerator $urlGenerator, |
68 | 64 | private ICloudFederationProviderManager $cloudFederationProviderManager, |
69 | 65 | private Config $config, |
70 | | - private IEventDispatcher $dispatcher, |
71 | | - private FederatedInviteMapper $federatedInviteMapper, |
72 | 66 | private readonly AddressHandler $addressHandler, |
73 | 67 | private readonly IAppConfig $appConfig, |
74 | 68 | private ICloudFederationFactory $factory, |
@@ -225,101 +219,6 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $ |
225 | 219 | return new JSONResponse($responseData, Http::STATUS_CREATED); |
226 | 220 | } |
227 | 221 |
|
228 | | - /** |
229 | | - * Inform the sender that an invitation was accepted to start sharing |
230 | | - * |
231 | | - * Inform about an accepted invitation so the user on the sender provider's side |
232 | | - * can initiate the OCM share creation. To protect the identity of the parties, |
233 | | - * for shares created following an OCM invitation, the user id MAY be hashed, |
234 | | - * and recipients implementing the OCM invitation workflow MAY refuse to process |
235 | | - * shares coming from unknown parties. |
236 | | - * @link https://cs3org.github.io/OCM-API/docs.html?branch=v1.1.0&repo=OCM-API&user=cs3org#/paths/~1invite-accepted/post |
237 | | - * |
238 | | - * @param string $recipientProvider The address of the recipent's provider |
239 | | - * @param string $token The token used for the invitation |
240 | | - * @param string $userID The userID of the recipient at the recipient's provider |
241 | | - * @param string $email The email address of the recipient |
242 | | - * @param string $name The display name of the recipient |
243 | | - * |
244 | | - * @return JSONResponse<Http::STATUS_OK, array{userID: string, email: string, name: string}, array{}>|JSONResponse<Http::STATUS_FORBIDDEN|Http::STATUS_BAD_REQUEST|Http::STATUS_CONFLICT, array{message: string, error: true}, array{}> |
245 | | - * |
246 | | - * Note: Not implementing 404 Invitation token does not exist, instead using 400 |
247 | | - * 200: Invitation accepted |
248 | | - * 400: Invalid token |
249 | | - * 403: Invitation token does not exist |
250 | | - * 409: User is already known by the OCM provider |
251 | | - */ |
252 | | - #[PublicPage] |
253 | | - #[NoCSRFRequired] |
254 | | - #[BruteForceProtection(action: 'inviteAccepted')] |
255 | | - public function inviteAccepted(string $recipientProvider, string $token, string $userID, string $email, string $name): JSONResponse { |
256 | | - $this->logger->debug('Processing share invitation for ' . $userID . ' with token ' . $token . ' and email ' . $email . ' and name ' . $name); |
257 | | - |
258 | | - $updated = $this->timeFactory->getTime(); |
259 | | - |
260 | | - if ($token === '') { |
261 | | - $response = new JSONResponse(['message' => 'Invalid or non existing token', 'error' => true], Http::STATUS_BAD_REQUEST); |
262 | | - $response->throttle(); |
263 | | - return $response; |
264 | | - } |
265 | | - |
266 | | - try { |
267 | | - $invitation = $this->federatedInviteMapper->findByToken($token); |
268 | | - } catch (DoesNotExistException) { |
269 | | - $response = ['message' => 'Invalid or non existing token', 'error' => true]; |
270 | | - $status = Http::STATUS_BAD_REQUEST; |
271 | | - $response = new JSONResponse($response, $status); |
272 | | - $response->throttle(); |
273 | | - return $response; |
274 | | - } |
275 | | - |
276 | | - if ($invitation->isAccepted() === true) { |
277 | | - $response = ['message' => 'Invite already accepted', 'error' => true]; |
278 | | - $status = Http::STATUS_CONFLICT; |
279 | | - return new JSONResponse($response, $status); |
280 | | - } |
281 | | - |
282 | | - if ($invitation->getExpiredAt() !== null && $updated > $invitation->getExpiredAt()) { |
283 | | - $response = ['message' => 'Invitation expired', 'error' => true]; |
284 | | - $status = Http::STATUS_BAD_REQUEST; |
285 | | - return new JSONResponse($response, $status); |
286 | | - } |
287 | | - $localUser = $this->userManager->get($invitation->getUserId()); |
288 | | - if ($localUser === null) { |
289 | | - $response = ['message' => 'Invalid or non existing token', 'error' => true]; |
290 | | - $status = Http::STATUS_BAD_REQUEST; |
291 | | - $response = new JSONResponse($response, $status); |
292 | | - $response->throttle(); |
293 | | - return $response; |
294 | | - } |
295 | | - |
296 | | - $sharedFromEmail = $localUser->getEMailAddress(); |
297 | | - if ($sharedFromEmail === null) { |
298 | | - $response = ['message' => 'Invalid or non existing token', 'error' => true]; |
299 | | - $status = Http::STATUS_BAD_REQUEST; |
300 | | - $response = new JSONResponse($response, $status); |
301 | | - $response->throttle(); |
302 | | - return $response; |
303 | | - } |
304 | | - $sharedFromDisplayName = $localUser->getDisplayName(); |
305 | | - |
306 | | - $response = ['userID' => $localUser->getUID(), 'email' => $sharedFromEmail, 'name' => $sharedFromDisplayName]; |
307 | | - $status = Http::STATUS_OK; |
308 | | - |
309 | | - $invitation->setAccepted(true); |
310 | | - $invitation->setRecipientEmail($email); |
311 | | - $invitation->setRecipientName($name); |
312 | | - $invitation->setRecipientProvider($recipientProvider); |
313 | | - $invitation->setRecipientUserId($userID); |
314 | | - $invitation->setAcceptedAt($updated); |
315 | | - $invitation = $this->federatedInviteMapper->update($invitation); |
316 | | - |
317 | | - $event = new FederatedInviteAcceptedEvent($invitation); |
318 | | - $this->dispatcher->dispatchTyped($event); |
319 | | - |
320 | | - return new JSONResponse($response, $status); |
321 | | - } |
322 | | - |
323 | 222 | /** |
324 | 223 | * Send a notification about an existing share |
325 | 224 | * |
|
0 commit comments