@@ -152,7 +152,7 @@ public function createShare(): DataResponse {
152152 $ share = $ this ->manager ->createShare ($ this ->accessContext );
153153
154154 $ this ->dbConnection ->commit ();
155- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ), Http::STATUS_CREATED );
155+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ), Http::STATUS_CREATED );
156156 } catch (Exception $ exception ) {
157157 $ this ->dbConnection ->rollBack ();
158158 throw $ exception ;
@@ -190,7 +190,7 @@ public function updateShareState(string $id, string $state): DataResponse {
190190 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
191191 $ share = $ this ->manager ->updateShareState ($ this ->accessContext , $ share , $ shareState );
192192 $ this ->dbConnection ->commit ();
193- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
193+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
194194 } catch (Exception $ exception ) {
195195 $ this ->dbConnection ->rollBack ();
196196 throw $ exception ;
@@ -229,7 +229,7 @@ public function updateShareUserStatus(string $id, string $userStatus): DataRespo
229229 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
230230 $ share = $ this ->manager ->updateShareUserStatus ($ this ->accessContext , $ share , $ shareUserStatus );
231231 $ this ->dbConnection ->commit ();
232- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
232+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
233233 } catch (Exception $ exception ) {
234234 $ this ->dbConnection ->rollBack ();
235235 throw $ exception ;
@@ -262,7 +262,7 @@ public function addShareSource(string $id, string $class, string $value): DataRe
262262 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
263263 $ share = $ this ->manager ->addShareSource ($ this ->accessContext , $ share , new ShareSource ($ class , $ value ));
264264 $ this ->dbConnection ->commit ();
265- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
265+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
266266 } catch (Exception $ exception ) {
267267 $ this ->dbConnection ->rollBack ();
268268 throw $ exception ;
@@ -298,7 +298,7 @@ public function removeShareSource(string $id, string $class, string $value): Dat
298298 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
299299 $ share = $ this ->manager ->removeShareSource ($ this ->accessContext , $ share , new ShareSource ($ class , $ value ));
300300 $ this ->dbConnection ->commit ();
301- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
301+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
302302 } catch (Exception $ exception ) {
303303 $ this ->dbConnection ->rollBack ();
304304 throw $ exception ;
@@ -334,7 +334,7 @@ public function addShareRecipient(string $id, string $class, string $value, ?str
334334 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
335335 $ share = $ this ->manager ->addShareRecipient ($ this ->accessContext , $ share , new ShareRecipient ($ class , $ value , $ instance ));
336336 $ this ->dbConnection ->commit ();
337- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
337+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
338338 } catch (Exception $ exception ) {
339339 $ this ->dbConnection ->rollBack ();
340340 throw $ exception ;
@@ -371,7 +371,7 @@ public function removeShareRecipient(string $id, string $class, string $value, ?
371371 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
372372 $ share = $ this ->manager ->removeShareRecipient ($ this ->accessContext , $ share , new ShareRecipient ($ class , $ value , $ instance ));
373373 $ this ->dbConnection ->commit ();
374- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
374+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
375375 } catch (Exception $ exception ) {
376376 $ this ->dbConnection ->rollBack ();
377377 throw $ exception ;
@@ -408,7 +408,7 @@ public function updateShareRecipientSecret(string $id, string $class, string $va
408408 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
409409 $ share = $ this ->manager ->updateShareRecipientSecret ($ this ->accessContext , $ share , new ShareRecipient ($ class , $ value , $ instance ), $ secret );
410410 $ this ->dbConnection ->commit ();
411- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
411+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
412412 } catch (Exception $ exception ) {
413413 $ this ->dbConnection ->rollBack ();
414414 throw $ exception ;
@@ -445,7 +445,7 @@ public function updateShareProperty(string $id, string $class, ?string $value):
445445 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
446446 $ share = $ this ->manager ->updateShareProperty ($ this ->accessContext , $ share , new ShareProperty ($ class , $ value ));
447447 $ this ->dbConnection ->commit ();
448- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
448+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
449449 } catch (Exception $ exception ) {
450450 $ this ->dbConnection ->rollBack ();
451451 throw $ exception ;
@@ -482,7 +482,7 @@ public function updateSharePermission(string $id, string $class, bool $enabled):
482482 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
483483 $ share = $ this ->manager ->updateSharePermission ($ this ->accessContext , $ share , new SharePermission ($ class , $ enabled ));
484484 $ this ->dbConnection ->commit ();
485- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
485+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
486486 } catch (Exception $ exception ) {
487487 $ this ->dbConnection ->rollBack ();
488488 throw $ exception ;
@@ -496,6 +496,43 @@ public function updateSharePermission(string $id, string $class, bool $enabled):
496496 }
497497 }
498498
499+ /**
500+ * Update a permission for a recipient of a share.
501+ *
502+ * @param string $id ID of the share
503+ * @param class-string<IShareRecipientType> $recipientClass Type class of the recipient
504+ * @param non-empty-string $recipientValue Value of the recipient
505+ * @param ?non-empty-string $recipientInstance Instance of the recipient
506+ * @param class-string<ISharePermissionType> $permissionClass Type class of the permission
507+ * @param bool $enabled Enabled state of the permission
508+ * @return DataResponse<Http::STATUS_OK, SharingShare, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, string, array{}>
509+ *
510+ * 200: Share recipient permission updated successfully
511+ * 403: Updating the share recipient permission is not allowed
512+ * 404: Share not found
513+ */
514+ #[NoAdminRequired]
515+ #[ApiRoute(verb: 'PUT ' , url: '/api/v1/share/{id}/recipient/permission ' )]
516+ public function updateShareRecipientPermission (string $ id , string $ recipientClass , string $ recipientValue , ?string $ recipientInstance , string $ permissionClass , bool $ enabled ): DataResponse {
517+ try {
518+ try {
519+ $ this ->dbConnection ->beginTransaction ();
520+
521+ $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
522+ $ share = $ this ->manager ->updateShareRecipientPermission ($ this ->accessContext , $ share , new ShareRecipient ($ recipientClass , $ recipientValue , $ recipientInstance ), new SharePermission ($ permissionClass , $ enabled ));
523+ $ this ->dbConnection ->commit ();
524+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this ->accessContext ));
525+ } catch (Exception $ exception ) {
526+ $ this ->dbConnection ->rollBack ();
527+ throw $ exception ;
528+ }
529+ } catch (ShareOperationForbiddenException $ shareOperationForbiddenException ) {
530+ return new DataResponse ($ shareOperationForbiddenException ->getHint (), Http::STATUS_FORBIDDEN );
531+ } catch (ShareNotFoundException $ shareNotFoundException ) {
532+ return new DataResponse ($ shareNotFoundException ->getHint (), Http::STATUS_NOT_FOUND );
533+ }
534+ }
535+
499536 /**
500537 * Select a permission preset for a share.
501538 *
@@ -518,7 +555,7 @@ public function selectSharePermissionPreset(string $id, string $permissionPreset
518555 $ share = $ this ->manager ->getShare ($ this ->accessContext , $ id );
519556 $ share = $ this ->manager ->selectSharePermissionPreset ($ this ->accessContext , $ share , $ permissionPresetClass );
520557 $ this ->dbConnection ->commit ();
521- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
558+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
522559 } catch (Exception $ exception ) {
523560 $ this ->dbConnection ->rollBack ();
524561 throw $ exception ;
@@ -583,7 +620,7 @@ public function getShare(string $id, ?string $secret = null, array $arguments =
583620
584621 $ share = $ this ->manager ->getShare (new ShareAccessContext ($ this ->accessContext ->currentUser , $ secret , $ arguments , $ this ->accessContext ->overrideChecks ), $ id );
585622 $ this ->dbConnection ->commit ();
586- return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager ));
623+ return new DataResponse ($ share ->format ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext ));
587624 } catch (Exception $ exception ) {
588625 $ this ->dbConnection ->rollBack ();
589626 throw $ exception ;
@@ -650,7 +687,7 @@ public function getShares(?string $filterSourceTypeClass, ?string $filterSourceT
650687
651688 $ shares = $ this ->manager ->getShares ($ this ->accessContext , $ filterSourceTypeClass , $ filterSourceTypeValue , $ filterState , $ filterUserStatus , $ lastShareID , $ limit );
652689 $ this ->dbConnection ->commit ();
653- return new DataResponse (Share::formatMultiple ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ shares ));
690+ return new DataResponse (Share::formatMultiple ($ this ->registry , $ this ->l10nFactory , $ this ->urlGenerator , $ this ->userManager , $ this -> accessContext , $ shares ));
654691 } catch (Exception $ exception ) {
655692 $ this ->dbConnection ->rollBack ();
656693 throw $ exception ;
0 commit comments