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