Skip to content

Commit 040d402

Browse files
committed
fix(ocm): Move invite-accepted capability and implementation to contacts app.
Backport of PR #57853 Signed-off-by: Antoon P. <antoon.prins@surf.nl>
1 parent 9f1a39b commit 040d402

18 files changed

Lines changed: 74 additions & 757 deletions

apps/cloud_federation_api/appinfo/info.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@
2121
<dependencies>
2222
<nextcloud min-version="33" max-version="33"/>
2323
</dependencies>
24+
25+
<repair-steps>
26+
<post-migration>
27+
<step>OCA\CloudFederationAPI\Migration\DropFederatedInvitesTable</step>
28+
</post-migration>
29+
</repair-steps>
2430
</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
@@ -8,13 +8,10 @@
88
return array(
99
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
1010
'OCA\\CloudFederationAPI\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
11-
'OCA\\CloudFederationAPI\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
1211
'OCA\\CloudFederationAPI\\Config' => $baseDir . '/../lib/Config.php',
1312
'OCA\\CloudFederationAPI\\Controller\\OCMRequestController' => $baseDir . '/../lib/Controller/OCMRequestController.php',
1413
'OCA\\CloudFederationAPI\\Controller\\RequestHandlerController' => $baseDir . '/../lib/Controller/RequestHandlerController.php',
15-
'OCA\\CloudFederationAPI\\Db\\FederatedInvite' => $baseDir . '/../lib/Db/FederatedInvite.php',
16-
'OCA\\CloudFederationAPI\\Db\\FederatedInviteMapper' => $baseDir . '/../lib/Db/FederatedInviteMapper.php',
17-
'OCA\\CloudFederationAPI\\Events\\FederatedInviteAcceptedEvent' => $baseDir . '/../lib/Events/FederatedInviteAcceptedEvent.php',
14+
'OCA\\CloudFederationAPI\\Migration\\DropFederatedInvitesTable' => $baseDir . '/../lib/Migration/DropFederatedInvitesTable.php',
1815
'OCA\\CloudFederationAPI\\Migration\\Version1016Date202502262004' => $baseDir . '/../lib/Migration/Version1016Date202502262004.php',
1916
'OCA\\CloudFederationAPI\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php',
2017
);

apps/cloud_federation_api/composer/composer/autoload_static.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@ class ComposerStaticInitCloudFederationAPI
2323
public static $classMap = array (
2424
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
2525
'OCA\\CloudFederationAPI\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
26-
'OCA\\CloudFederationAPI\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
2726
'OCA\\CloudFederationAPI\\Config' => __DIR__ . '/..' . '/../lib/Config.php',
2827
'OCA\\CloudFederationAPI\\Controller\\OCMRequestController' => __DIR__ . '/..' . '/../lib/Controller/OCMRequestController.php',
2928
'OCA\\CloudFederationAPI\\Controller\\RequestHandlerController' => __DIR__ . '/..' . '/../lib/Controller/RequestHandlerController.php',
30-
'OCA\\CloudFederationAPI\\Db\\FederatedInvite' => __DIR__ . '/..' . '/../lib/Db/FederatedInvite.php',
31-
'OCA\\CloudFederationAPI\\Db\\FederatedInviteMapper' => __DIR__ . '/..' . '/../lib/Db/FederatedInviteMapper.php',
32-
'OCA\\CloudFederationAPI\\Events\\FederatedInviteAcceptedEvent' => __DIR__ . '/..' . '/../lib/Events/FederatedInviteAcceptedEvent.php',
29+
'OCA\\CloudFederationAPI\\Migration\\DropFederatedInvitesTable' => __DIR__ . '/..' . '/../lib/Migration/DropFederatedInvitesTable.php',
3330
'OCA\\CloudFederationAPI\\Migration\\Version1016Date202502262004' => __DIR__ . '/..' . '/../lib/Migration/Version1016Date202502262004.php',
3431
'OCA\\CloudFederationAPI\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php',
3532
);

apps/cloud_federation_api/lib/AppInfo/Application.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
namespace OCA\CloudFederationAPI\AppInfo;
1010

11-
use OCA\CloudFederationAPI\Capabilities;
1211
use OCP\AppFramework\App;
1312
use OCP\AppFramework\Bootstrap\IBootContext;
1413
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -22,7 +21,6 @@ public function __construct() {
2221
}
2322

2423
public function register(IRegistrationContext $context): void {
25-
$context->registerCapability(Capabilities::class);
2624
}
2725

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

apps/cloud_federation_api/lib/Capabilities.php

Lines changed: 0 additions & 33 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\AppFramework\Http\Attributes\FederationRateLimit;
1111
use OC\OCM\OCMSignatoryManager;
1212
use OCA\CloudFederationAPI\Config;
13-
use OCA\CloudFederationAPI\Db\FederatedInviteMapper;
14-
use OCA\CloudFederationAPI\Events\FederatedInviteAcceptedEvent;
1513
use OCA\CloudFederationAPI\ResponseDefinitions;
1614
use OCA\FederatedFileSharing\AddressHandler;
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 AddressHandler $addressHandler,
7470
private readonly IAppConfig $appConfig,
7571
private ICloudFederationFactory $factory,
@@ -249,101 +245,6 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
249245
return new JSONResponse($responseData, Http::STATUS_CREATED);
250246
}
251247

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-
347248
/**
348249
* Send a notification about an existing share
349250
*

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)