Skip to content

Commit 3f2f766

Browse files
committed
Move invite-accepted capability and implementation to contacts app.
Signed-off-by: antoonp <antoon@redblom.com>
1 parent ebfdbf8 commit 3f2f766

9 files changed

Lines changed: 1 addition & 452 deletions

File tree

apps/cloud_federation_api/appinfo/routes.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
'verb' => 'POST',
2121
'root' => '/ocm',
2222
],
23-
[
24-
'name' => 'RequestHandler#inviteAccepted',
25-
'url' => '/invite-accepted',
26-
'verb' => 'POST',
27-
'root' => '/ocm',
28-
],
2923

3024
// needs to be kept at the bottom of the list
3125
[

apps/cloud_federation_api/lib/AppInfo/Application.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public function __construct() {
2222
}
2323

2424
public function register(IRegistrationContext $context): void {
25-
$context->registerCapability(Capabilities::class);
2625
}
2726

2827
public function boot(IBootContext $context): void {

apps/cloud_federation_api/lib/Controller/RequestHandlerController.php

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public function __construct(
6767
private IURLGenerator $urlGenerator,
6868
private ICloudFederationProviderManager $cloudFederationProviderManager,
6969
private Config $config,
70-
private IEventDispatcher $dispatcher,
71-
private FederatedInviteMapper $federatedInviteMapper,
7270
private readonly AddressHandler $addressHandler,
7371
private readonly IAppConfig $appConfig,
7472
private ICloudFederationFactory $factory,
@@ -225,101 +223,6 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
225223
return new JSONResponse($responseData, Http::STATUS_CREATED);
226224
}
227225

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-
323226
/**
324227
* Send a notification about an existing share
325228
*

apps/cloud_federation_api/lib/Db/FederatedInvite.php

Lines changed: 0 additions & 62 deletions
This file was deleted.

apps/cloud_federation_api/lib/Db/FederatedInviteMapper.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

apps/cloud_federation_api/lib/Events/FederatedInviteAcceptedEvent.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

apps/cloud_federation_api/lib/Migration/Version1016Date202502262004.php

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)