Skip to content

Commit ccaa4c5

Browse files
authored
Merge pull request #57853 from redblom/move-ocm-invite-accepted-route-impl-to-contacts-app
Move invite-accepted capability and implementation to contacts app.
2 parents 41d6b09 + 5cbdfac commit ccaa4c5

20 files changed

Lines changed: 76 additions & 885 deletions

apps/cloud_federation_api/appinfo/info.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@
2525
<background-jobs>
2626
<job>OCA\CloudFederationAPI\BackgroundJob\CleanupExpiredOcmTokensJob</job>
2727
</background-jobs>
28+
<repair-steps>
29+
<post-migration>
30+
<step>OCA\CloudFederationAPI\Migration\DropFederatedInvitesTable</step>
31+
</post-migration>
32+
</repair-steps>
2833
</info>

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/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
1010
'OCA\\CloudFederationAPI\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
1111
'OCA\\CloudFederationAPI\\BackgroundJob\\CleanupExpiredOcmTokensJob' => $baseDir . '/../lib/BackgroundJob/CleanupExpiredOcmTokensJob.php',
12-
'OCA\\CloudFederationAPI\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
1312
'OCA\\CloudFederationAPI\\Config' => $baseDir . '/../lib/Config.php',
1413
'OCA\\CloudFederationAPI\\Controller\\OCMRequestController' => $baseDir . '/../lib/Controller/OCMRequestController.php',
1514
'OCA\\CloudFederationAPI\\Controller\\RequestHandlerController' => $baseDir . '/../lib/Controller/RequestHandlerController.php',
1615
'OCA\\CloudFederationAPI\\Controller\\TokenController' => $baseDir . '/../lib/Controller/TokenController.php',
17-
'OCA\\CloudFederationAPI\\Db\\FederatedInvite' => $baseDir . '/../lib/Db/FederatedInvite.php',
18-
'OCA\\CloudFederationAPI\\Db\\FederatedInviteMapper' => $baseDir . '/../lib/Db/FederatedInviteMapper.php',
1916
'OCA\\CloudFederationAPI\\Db\\OcmTokenMap' => $baseDir . '/../lib/Db/OcmTokenMap.php',
2017
'OCA\\CloudFederationAPI\\Db\\OcmTokenMapMapper' => $baseDir . '/../lib/Db/OcmTokenMapMapper.php',
21-
'OCA\\CloudFederationAPI\\Events\\FederatedInviteAcceptedEvent' => $baseDir . '/../lib/Events/FederatedInviteAcceptedEvent.php',
18+
'OCA\\CloudFederationAPI\\Migration\\DropFederatedInvitesTable' => $baseDir . '/../lib/Migration/DropFederatedInvitesTable.php',
2219
'OCA\\CloudFederationAPI\\Migration\\Version1016Date202502262004' => $baseDir . '/../lib/Migration/Version1016Date202502262004.php',
2320
'OCA\\CloudFederationAPI\\Migration\\Version1017Date20260306120000' => $baseDir . '/../lib/Migration/Version1017Date20260306120000.php',
2421
'OCA\\CloudFederationAPI\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php',

apps/cloud_federation_api/composer/composer/autoload_static.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@ class ComposerStaticInitCloudFederationAPI
2424
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
2525
'OCA\\CloudFederationAPI\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
2626
'OCA\\CloudFederationAPI\\BackgroundJob\\CleanupExpiredOcmTokensJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/CleanupExpiredOcmTokensJob.php',
27-
'OCA\\CloudFederationAPI\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
2827
'OCA\\CloudFederationAPI\\Config' => __DIR__ . '/..' . '/../lib/Config.php',
2928
'OCA\\CloudFederationAPI\\Controller\\OCMRequestController' => __DIR__ . '/..' . '/../lib/Controller/OCMRequestController.php',
3029
'OCA\\CloudFederationAPI\\Controller\\RequestHandlerController' => __DIR__ . '/..' . '/../lib/Controller/RequestHandlerController.php',
3130
'OCA\\CloudFederationAPI\\Controller\\TokenController' => __DIR__ . '/..' . '/../lib/Controller/TokenController.php',
32-
'OCA\\CloudFederationAPI\\Db\\FederatedInvite' => __DIR__ . '/..' . '/../lib/Db/FederatedInvite.php',
33-
'OCA\\CloudFederationAPI\\Db\\FederatedInviteMapper' => __DIR__ . '/..' . '/../lib/Db/FederatedInviteMapper.php',
3431
'OCA\\CloudFederationAPI\\Db\\OcmTokenMap' => __DIR__ . '/..' . '/../lib/Db/OcmTokenMap.php',
3532
'OCA\\CloudFederationAPI\\Db\\OcmTokenMapMapper' => __DIR__ . '/..' . '/../lib/Db/OcmTokenMapMapper.php',
36-
'OCA\\CloudFederationAPI\\Events\\FederatedInviteAcceptedEvent' => __DIR__ . '/..' . '/../lib/Events/FederatedInviteAcceptedEvent.php',
33+
'OCA\\CloudFederationAPI\\Migration\\DropFederatedInvitesTable' => __DIR__ . '/..' . '/../lib/Migration/DropFederatedInvitesTable.php',
3734
'OCA\\CloudFederationAPI\\Migration\\Version1016Date202502262004' => __DIR__ . '/..' . '/../lib/Migration/Version1016Date202502262004.php',
3835
'OCA\\CloudFederationAPI\\Migration\\Version1017Date20260306120000' => __DIR__ . '/..' . '/../lib/Migration/Version1017Date20260306120000.php',
3936
'OCA\\CloudFederationAPI\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php',

apps/cloud_federation_api/lib/AppInfo/Application.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace OCA\CloudFederationAPI\AppInfo;
1111

12-
use OCA\CloudFederationAPI\Capabilities;
1312
use OCP\AppFramework\App;
1413
use OCP\AppFramework\Bootstrap\IBootContext;
1514
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -24,7 +23,6 @@ public function __construct() {
2423

2524
#[\Override]
2625
public function register(IRegistrationContext $context): void {
27-
$context->registerCapability(Capabilities::class);
2826
}
2927

3028
#[\Override]

apps/cloud_federation_api/lib/Capabilities.php

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

apps/cloud_federation_api/lib/Controller/RequestHandlerController.php

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010
use OC\Authentication\Token\PublicKeyTokenProvider;
1111
use OC\OCM\OCMSignatoryManager;
1212
use OCA\CloudFederationAPI\Config;
13-
use OCA\CloudFederationAPI\Db\FederatedInviteMapper;
1413
use OCA\CloudFederationAPI\Db\OcmTokenMapMapper;
15-
use OCA\CloudFederationAPI\Events\FederatedInviteAcceptedEvent;
1614
use OCA\CloudFederationAPI\ResponseDefinitions;
1715
use OCP\AppFramework\Controller;
18-
use OCP\AppFramework\Db\DoesNotExistException;
1916
use OCP\AppFramework\Http;
2017
use OCP\AppFramework\Http\Attribute\BruteForceProtection;
2118
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
@@ -69,7 +66,6 @@ public function __construct(
6966
private ICloudFederationProviderManager $cloudFederationProviderManager,
7067
private Config $config,
7168
private IEventDispatcher $dispatcher,
72-
private FederatedInviteMapper $federatedInviteMapper,
7369
private readonly IAppConfig $appConfig,
7470
private ICloudFederationFactory $factory,
7571
private ICloudIdManager $cloudIdManager,
@@ -272,101 +268,6 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
272268
return new JSONResponse($responseData, Http::STATUS_CREATED);
273269
}
274270

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-
370271
/**
371272
* Send a notification about an existing share
372273
*

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.

0 commit comments

Comments
 (0)