Skip to content

Commit 453d8ba

Browse files
Merge pull request #62486 from redblom/backport/57853/stable34
[stable34] fix(ocm): Move invite-accepted capability and implementation to contacts app
2 parents c164653 + 1b68ccd commit 453d8ba

18 files changed

Lines changed: 74 additions & 800 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="34" max-version="34"/>
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;
@@ -23,7 +22,6 @@ public function __construct() {
2322

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

2927
#[\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\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;
@@ -70,7 +67,6 @@ public function __construct(
7067
private ICloudFederationProviderManager $cloudFederationProviderManager,
7168
private Config $config,
7269
private IEventDispatcher $dispatcher,
73-
private FederatedInviteMapper $federatedInviteMapper,
7470
private readonly AddressHandler $addressHandler,
7571
private readonly IAppConfig $appConfig,
7672
private ICloudFederationFactory $factory,
@@ -250,101 +246,6 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
250246
return new JSONResponse($responseData, Http::STATUS_CREATED);
251247
}
252248

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

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)