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