|
10 | 10 | use OC\Authentication\Token\PublicKeyTokenProvider; |
11 | 11 | use OC\OCM\OCMSignatoryManager; |
12 | 12 | use OCA\CloudFederationAPI\Config; |
13 | | -use OCA\CloudFederationAPI\Db\FederatedInviteMapper; |
14 | 13 | use OCA\CloudFederationAPI\Db\OcmTokenMapMapper; |
15 | | -use OCA\CloudFederationAPI\Events\FederatedInviteAcceptedEvent; |
16 | 14 | use OCA\CloudFederationAPI\ResponseDefinitions; |
17 | 15 | use OCP\AppFramework\Controller; |
18 | | -use OCP\AppFramework\Db\DoesNotExistException; |
19 | 16 | use OCP\AppFramework\Http; |
20 | 17 | use OCP\AppFramework\Http\Attribute\BruteForceProtection; |
21 | 18 | use OCP\AppFramework\Http\Attribute\NoCSRFRequired; |
@@ -69,7 +66,6 @@ public function __construct( |
69 | 66 | private ICloudFederationProviderManager $cloudFederationProviderManager, |
70 | 67 | private Config $config, |
71 | 68 | private IEventDispatcher $dispatcher, |
72 | | - private FederatedInviteMapper $federatedInviteMapper, |
73 | 69 | private readonly IAppConfig $appConfig, |
74 | 70 | private ICloudFederationFactory $factory, |
75 | 71 | private ICloudIdManager $cloudIdManager, |
@@ -272,101 +268,6 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $ |
272 | 268 | return new JSONResponse($responseData, Http::STATUS_CREATED); |
273 | 269 | } |
274 | 270 |
|
275 | | - /** |
276 | | - * Inform the sender that an invitation was accepted to start sharing |
277 | | - * |
278 | | - * Inform about an accepted invitation so the user on the sender provider's side |
279 | | - * can initiate the OCM share creation. To protect the identity of the parties, |
280 | | - * for shares created following an OCM invitation, the user id MAY be hashed, |
281 | | - * and recipients implementing the OCM invitation workflow MAY refuse to process |
282 | | - * shares coming from unknown parties. |
283 | | - * @link https://cs3org.github.io/OCM-API/docs.html?branch=v1.1.0&repo=OCM-API&user=cs3org#/paths/~1invite-accepted/post |
284 | | - * |
285 | | - * @param string $recipientProvider The address of the recipent's provider |
286 | | - * @param string $token The token used for the invitation |
287 | | - * @param string $userID The userID of the recipient at the recipient's provider |
288 | | - * @param string $email The email address of the recipient |
289 | | - * @param string $name The display name of the recipient |
290 | | - * |
291 | | - * @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{}> |
292 | | - * |
293 | | - * Note: Not implementing 404 Invitation token does not exist, instead using 400 |
294 | | - * 200: Invitation accepted |
295 | | - * 400: Invalid token |
296 | | - * 403: Invitation token does not exist |
297 | | - * 409: User is already known by the OCM provider |
298 | | - */ |
299 | | - #[PublicPage] |
300 | | - #[NoCSRFRequired] |
301 | | - #[BruteForceProtection(action: 'inviteAccepted')] |
302 | | - public function inviteAccepted(string $recipientProvider, string $token, string $userID, string $email, string $name): JSONResponse { |
303 | | - $this->logger->debug('Processing share invitation for ' . $userID . ' with token ' . $token . ' and email ' . $email . ' and name ' . $name); |
304 | | - |
305 | | - $updated = $this->timeFactory->getTime(); |
306 | | - |
307 | | - if ($token === '') { |
308 | | - $response = new JSONResponse(['message' => 'Invalid or non existing token', 'error' => true], Http::STATUS_BAD_REQUEST); |
309 | | - $response->throttle(); |
310 | | - return $response; |
311 | | - } |
312 | | - |
313 | | - try { |
314 | | - $invitation = $this->federatedInviteMapper->findByToken($token); |
315 | | - } catch (DoesNotExistException) { |
316 | | - $response = ['message' => 'Invalid or non existing token', 'error' => true]; |
317 | | - $status = Http::STATUS_BAD_REQUEST; |
318 | | - $response = new JSONResponse($response, $status); |
319 | | - $response->throttle(); |
320 | | - return $response; |
321 | | - } |
322 | | - |
323 | | - if ($invitation->isAccepted() === true) { |
324 | | - $response = ['message' => 'Invite already accepted', 'error' => true]; |
325 | | - $status = Http::STATUS_CONFLICT; |
326 | | - return new JSONResponse($response, $status); |
327 | | - } |
328 | | - |
329 | | - if ($invitation->getExpiredAt() !== null && $updated > $invitation->getExpiredAt()) { |
330 | | - $response = ['message' => 'Invitation expired', 'error' => true]; |
331 | | - $status = Http::STATUS_BAD_REQUEST; |
332 | | - return new JSONResponse($response, $status); |
333 | | - } |
334 | | - $localUser = $this->userManager->get($invitation->getUserId()); |
335 | | - if ($localUser === null) { |
336 | | - $response = ['message' => 'Invalid or non existing token', 'error' => true]; |
337 | | - $status = Http::STATUS_BAD_REQUEST; |
338 | | - $response = new JSONResponse($response, $status); |
339 | | - $response->throttle(); |
340 | | - return $response; |
341 | | - } |
342 | | - |
343 | | - $sharedFromEmail = $localUser->getEMailAddress(); |
344 | | - if ($sharedFromEmail === null) { |
345 | | - $response = ['message' => 'Invalid or non existing token', 'error' => true]; |
346 | | - $status = Http::STATUS_BAD_REQUEST; |
347 | | - $response = new JSONResponse($response, $status); |
348 | | - $response->throttle(); |
349 | | - return $response; |
350 | | - } |
351 | | - $sharedFromDisplayName = $localUser->getDisplayName(); |
352 | | - |
353 | | - $response = ['userID' => $localUser->getUID(), 'email' => $sharedFromEmail, 'name' => $sharedFromDisplayName]; |
354 | | - $status = Http::STATUS_OK; |
355 | | - |
356 | | - $invitation->setAccepted(true); |
357 | | - $invitation->setRecipientEmail($email); |
358 | | - $invitation->setRecipientName($name); |
359 | | - $invitation->setRecipientProvider($recipientProvider); |
360 | | - $invitation->setRecipientUserId($userID); |
361 | | - $invitation->setAcceptedAt($updated); |
362 | | - $invitation = $this->federatedInviteMapper->update($invitation); |
363 | | - |
364 | | - $event = new FederatedInviteAcceptedEvent($invitation); |
365 | | - $this->dispatcher->dispatchTyped($event); |
366 | | - |
367 | | - return new JSONResponse($response, $status); |
368 | | - } |
369 | | - |
370 | 271 | /** |
371 | 272 | * Send a notification about an existing share |
372 | 273 | * |
|
0 commit comments