@@ -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 *
0 commit comments