@@ -156,7 +156,7 @@ public function createShare(): DataResponse {
156156 $ share = $ this ->manager ->createShare ($ this ->accessContext );
157157
158158 $ this ->dbConnection ->commit ();
159- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ), Http::STATUS_CREATED );
159+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ), Http::STATUS_CREATED );
160160 } catch (Exception $ exception ) {
161161 $ this ->dbConnection ->rollBack ();
162162 throw $ exception ;
@@ -195,7 +195,7 @@ public function updateShareState(string $id, string $state): DataResponse {
195195 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
196196 $ share = $ this ->manager ->updateShareState ($ this ->accessContext , $ share , $ shareState );
197197 $ this ->dbConnection ->commit ();
198- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
198+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
199199 } catch (Exception $ exception ) {
200200 $ this ->dbConnection ->rollBack ();
201201 throw $ exception ;
@@ -235,7 +235,7 @@ public function updateShareUserStatus(string $id, string $userStatus): DataRespo
235235 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
236236 $ share = $ this ->manager ->updateShareUserStatus ($ this ->accessContext , $ share , $ shareUserStatus );
237237 $ this ->dbConnection ->commit ();
238- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
238+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
239239 } catch (Exception $ exception ) {
240240 $ this ->dbConnection ->rollBack ();
241241 throw $ exception ;
@@ -269,7 +269,7 @@ public function addShareSource(string $id, string $class, string $value): DataRe
269269 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
270270 $ share = $ this ->manager ->addShareSource ($ this ->accessContext , $ share , new ShareSource ($ class , $ value ));
271271 $ this ->dbConnection ->commit ();
272- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
272+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
273273 } catch (Exception $ exception ) {
274274 $ this ->dbConnection ->rollBack ();
275275 throw $ exception ;
@@ -306,7 +306,7 @@ public function removeShareSource(string $id, string $class, string $value): Dat
306306 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
307307 $ share = $ this ->manager ->removeShareSource ($ this ->accessContext , $ share , new ShareSource ($ class , $ value ));
308308 $ this ->dbConnection ->commit ();
309- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
309+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
310310 } catch (Exception $ exception ) {
311311 $ this ->dbConnection ->rollBack ();
312312 throw $ exception ;
@@ -343,7 +343,7 @@ public function addShareRecipient(string $id, string $class, string $value, ?str
343343 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
344344 $ share = $ this ->manager ->addShareRecipient ($ this ->accessContext , $ share , new ShareRecipient ($ class , $ value , $ instance ));
345345 $ this ->dbConnection ->commit ();
346- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
346+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
347347 } catch (Exception $ exception ) {
348348 $ this ->dbConnection ->rollBack ();
349349 throw $ exception ;
@@ -381,7 +381,7 @@ public function removeShareRecipient(string $id, string $class, string $value, ?
381381 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
382382 $ share = $ this ->manager ->removeShareRecipient ($ this ->accessContext , $ share , new ShareRecipient ($ class , $ value , $ instance ));
383383 $ this ->dbConnection ->commit ();
384- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
384+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
385385 } catch (Exception $ exception ) {
386386 $ this ->dbConnection ->rollBack ();
387387 throw $ exception ;
@@ -419,7 +419,7 @@ public function updateShareRecipientSecret(string $id, string $class, string $va
419419 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
420420 $ share = $ this ->manager ->updateShareRecipientSecret ($ this ->accessContext , $ share , new ShareRecipient ($ class , $ value , $ instance ), $ secret );
421421 $ this ->dbConnection ->commit ();
422- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
422+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
423423 } catch (Exception $ exception ) {
424424 $ this ->dbConnection ->rollBack ();
425425 throw $ exception ;
@@ -457,7 +457,7 @@ public function updateShareProperty(string $id, string $class, ?string $value):
457457 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
458458 $ share = $ this ->manager ->updateShareProperty ($ this ->accessContext , $ share , new ShareProperty ($ class , $ value ));
459459 $ this ->dbConnection ->commit ();
460- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
460+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
461461 } catch (Exception $ exception ) {
462462 $ this ->dbConnection ->rollBack ();
463463 throw $ exception ;
@@ -495,7 +495,7 @@ public function updateSharePermission(string $id, string $class, bool $enabled):
495495 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
496496 $ share = $ this ->manager ->updateSharePermission ($ this ->accessContext , $ share , new SharePermission ($ class , $ enabled ));
497497 $ this ->dbConnection ->commit ();
498- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
498+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
499499 } catch (Exception $ exception ) {
500500 $ this ->dbConnection ->rollBack ();
501501 throw $ exception ;
@@ -509,6 +509,43 @@ public function updateSharePermission(string $id, string $class, bool $enabled):
509509 }
510510 }
511511
512+ /**
513+ * Update a permission for a recipient of a share.
514+ *
515+ * @param string $id ID of the share
516+ * @param class-string<IShareRecipientType> $recipientClass Type class of the recipient
517+ * @param non-empty-string $recipientValue Value of the recipient
518+ * @param ?non-empty-string $recipientInstance Instance of the recipient
519+ * @param class-string<ISharePermissionType> $permissionClass Type class of the permission
520+ * @param bool $enabled Enabled state of the permission
521+ * @return DataResponse<Http::STATUS_OK, SharingShare, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, string, array{}>
522+ *
523+ * 200: Share recipient permission updated successfully
524+ * 403: Updating the share recipient permission is not allowed
525+ * 404: Share not found
526+ */
527+ #[NoAdminRequired]
528+ #[ApiRoute(verb: 'PUT ' , url: '/api/v1/share/{id}/recipient/permission ' )]
529+ public function updateShareRecipientPermission (string $ id , string $ recipientClass , string $ recipientValue , ?string $ recipientInstance , string $ permissionClass , bool $ enabled ): DataResponse {
530+ try {
531+ try {
532+ $ this ->dbConnection ->beginTransaction ();
533+
534+ $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
535+ $ share = $ this ->manager ->updateShareRecipientPermission ($ this ->accessContext , $ share , new ShareRecipient ($ recipientClass , $ recipientValue , $ recipientInstance ), new SharePermission ($ permissionClass , $ enabled ));
536+ $ this ->dbConnection ->commit ();
537+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this ->accessContext ));
538+ } catch (Exception $ exception ) {
539+ $ this ->dbConnection ->rollBack ();
540+ throw $ exception ;
541+ }
542+ } catch (ShareOperationForbiddenException $ shareOperationForbiddenException ) {
543+ return new DataResponse ($ shareOperationForbiddenException ->getHint (), Http::STATUS_FORBIDDEN );
544+ } catch (ShareNotFoundException $ shareNotFoundException ) {
545+ return new DataResponse ($ shareNotFoundException ->getHint (), Http::STATUS_NOT_FOUND );
546+ }
547+ }
548+
512549 /**
513550 * Select a permission preset for a share.
514551 *
@@ -532,7 +569,7 @@ public function selectSharePermissionPreset(string $id, string $permissionPreset
532569 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
533570 $ share = $ this ->manager ->selectSharePermissionPreset ($ this ->accessContext , $ share , $ permissionPresetClass );
534571 $ this ->dbConnection ->commit ();
535- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
572+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
536573 } catch (Exception $ exception ) {
537574 $ this ->dbConnection ->rollBack ();
538575 throw $ exception ;
@@ -601,7 +638,7 @@ public function getShare(string $id, ?string $secret = null, array $arguments =
601638
602639 $ share = $ this ->manager ->getShare (new ShareAccessContext ($ this ->accessContext ->currentUser , $ secret , $ arguments , $ this ->accessContext ->overrideChecks ), $ id );
603640 $ this ->dbConnection ->commit ();
604- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
641+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
605642 } catch (Exception $ exception ) {
606643 $ this ->dbConnection ->rollBack ();
607644 throw $ exception ;
@@ -672,7 +709,7 @@ public function getShares(?string $filterSourceTypeClass, ?string $filterSourceT
672709
673710 $ shares = $ this ->manager ->getShares ($ this ->accessContext , $ filterSourceTypeClass , $ filterSourceTypeValue , $ filterState , $ filterUserStatus , $ lastShareID , $ limit );
674711 $ this ->dbConnection ->commit ();
675- return new DataResponse (Share::formatMultiple ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ shares ));
712+ return new DataResponse (Share::formatMultiple ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext , $ shares ));
676713 } catch (Exception $ exception ) {
677714 $ this ->dbConnection ->rollBack ();
678715 throw $ exception ;
0 commit comments